gpt4 book ai didi

python - PySpark:当函数具有多个输出时

转载 作者:太空狗 更新时间:2023-10-29 19:35:07 32 4
gpt4 key购买 nike

<分区>

我正在尝试使用“链接时间”函数。换句话说,我想要获得两个以上的输出。

我尝试在 Excel 中使用与连接 IF 函数相同的逻辑:

  df.withColumn("device_id", when(col("device")=="desktop",1)).otherwise(when(col("device")=="mobile",2)).otherwise(null))

但这不起作用,因为我不能将元组放入“otherwise”函数中。

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com