我有一个低于pyspark的DataFrame[recoms: string]
,其中recoms
列的值是字符串类型。每一行在这里代表一个字符串。你知道吗
+--------------------+
| recoms |
+--------------------+
|{"a":"1","b":"5",..}|
|{"a":"2","b":"4",..}|
|{"a":"3","b":"9",..}|
+--------------------+
上面的行没有定义的模式来使用from\u json方法。所以呢我在找其他的选择。如何使用pysparksql函数转换或拆分为多值dataframe列,如下所示。在上表中,:
左边的所有值都是dataframe列名,:
右边的所有值都是行值。你知道吗
+--------+---+
| a | b |
+--------+---+
| 1 | 5|
| 2 | 4|
| 3 | 9|
+--------+---+
我试过分解sql函数
df.select(explode("recoms")).show()
并得到以下错误。你知道吗
org.apache.spark.sql.AnalysisException: cannot resolve 'explode(true_recoms)' due to data type mismatch: input to function explode should be array or map type, not string;;
目前没有回答
相关问题 更多 >
编程相关推荐