【发布时间】:2017-07-21 02:16:08
【问题描述】:
我正在尝试使用“链接时”功能。 换句话说,我想得到两个以上的输出。
我尝试在 Excel 中使用与连接 IF 函数相同的逻辑:
df.withColumn("device_id", when(col("device")=="desktop",1)).otherwise(when(col("device")=="mobile",2)).otherwise(null))
但这不起作用,因为我无法将元组放入“否则”函数中。
【问题讨论】:
标签: python apache-spark pyspark pyspark-sql