Ipp*_*pon 0 apache-spark apache-spark-sql pyspark spark-dataframe
我有以下结构的数据框:
root
|-- index: long (nullable = true)
|-- text: string (nullable = true)
|-- topicDistribution: struct (nullable = true)
| |-- type: long (nullable = true)
| |-- values: array (nullable = true)
| | |-- element: double (containsNull = true)
|-- wiki_index: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
我需要将其更改为:
root
|-- index: long (nullable = true)
|-- text: string (nullable = true)
|-- topicDistribution: array (nullable = true)
| |-- element: double (containsNull = true)
|-- wiki_index: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
请问我该怎么做?
非常感谢。
我想你在找
df.withColumn("topicDistribution", col("topicDistribution").getField("values"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2729 次 |
| 最近记录: |