Spark Sql Pivot问题-列不可迭代

时间:2019-07-17 12:42:57

标签: pyspark apache-spark-sql pyspark-sql

我一直在尝试在pyspark中旋转数据框。这样做时,我得到column is not iterable error. Column "find_typ_J_8" has values "J" and "8", for each VBELN_7 value, either both J and 8 types present or only one of find_type present.

这是我正在使用的示例数据框:

   VBELN_7 |vbtyp_7|  find_J_8|find_typ_J_8|
+----------+-------+----------+------------+
|0x0x782x3v|      7|0032101161|           J|
|0n1t026y97|      7|0032645476|           J|

代码:

from pyspark.sql import functions as F
tmp5.groupBy(F.col("VBELN_7"),F.col("vbtyp_7")).pivot(F.col("find_typ_J_8"), ['J', '8']).agg(F.first(F.col("find_J_8"),False))

0 个答案:

没有答案