How can we cast the column that contains values of multiple types to single data type using glue dynamic dataframe python
Question:
How can we cast the column that contains values of multiple types to single data type. I am using resolveChoice method but still it doesn’t convert the multple types to single data type using glue dynamic dataframe python.
code
df = df.resolveChoice(specs=[("Offset", "cast:long")])
Input schema
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
Current Output Schema
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
Expected Output Schema
dec: array
-- element: struct
|-- Offset: long
Answers:
You need to input the whole "path" of the property:
df = df.resolveChoice(specs=[("dec[].Offset", "cast:long")])
How can we cast the column that contains values of multiple types to single data type. I am using resolveChoice method but still it doesn’t convert the multple types to single data type using glue dynamic dataframe python.
code
df = df.resolveChoice(specs=[("Offset", "cast:long")])
Input schema
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
Current Output Schema
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
Expected Output Schema
dec: array
-- element: struct
|-- Offset: long
You need to input the whole "path" of the property:
df = df.resolveChoice(specs=[("dec[].Offset", "cast:long")])