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
Asked By: Manish

||

Answers:

You need to input the whole "path" of the property:

df = df.resolveChoice(specs=[("dec[].Offset", "cast:long")])
Answered By: Robert Kossendey
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.