【发布时间】:2019-03-15 05:27:43
【问题描述】:
df.printSchema()
root
|-- country: struct (nullable = true)
| |-- a: long (nullable = true)
| |-- b: string (nullable = true)
| |-- c: string (nullable = true)
| |-- d: string (nullable = true)
Row(trustset=Row(a=1, b='Melbourne is in Aus', c=None, d='Sydney'))
df.show()
+--------------------+
| trustset|
+--------------------+
|[1, Melbourne is ...|
+--------------------+
我想要的输出必须是
+------+------------------------+-----+--------+
| a | b | c | d |
+------+------------------------+-----+--------+
| 1 | Melbourne is in Aus | None| Sydney |
+------+------------------------+-----+--------+
已经获得信任,因为该列需要以 subs 作为主要列
【问题讨论】:
-
df.select(df.col("trustset.*")) 见stackoverflow.com/questions/38753898/…
-
用过这个
df.select(df.columns("trustset.*"))得到TypeError: 'list' object is not callable用这个df.select(df.col("trustset.*"))得到AttributeError: 'DataFrame' object has no attribute 'col' -
没有嵌套 JSON 这样的东西。 JSON 是一些数据结构的文本表示。而且问题中没有 JSON。
标签: apache-spark pyspark apache-spark-sql