英文:
How can we cast the column that contains values of multiple types to single data type using glue dynamic dataframe python
问题
如何将包含多种类型值的列转换为单一数据类型。我正在使用 resolveChoice 方法,但仍无法将多种类型转换为单一数据类型,使用 Glue 动态数据框架 Python。
代码
df = df.resolveChoice(specs=[("Offset", "cast:long")])
输入模式
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
当前输出模式
- dec: array
-- element: struct
|-- Offset: choice
| |-- long
| |-- string
预期输出模式
dec: array
-- element: struct
|-- Offset: 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
答案1
得分: 0
你需要输入属性的完整“路径”:
df = df.resolveChoice(specs=[("dec[].Offset", "cast:long")])
英文:
You need to input the whole "path" of the property:
df = df.resolveChoice(specs=[("dec[].Offset", "cast:long")])
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论