我正在努力创建一个新的专栏基于一个简单的条件比较两个日期。我尝试了以下方法:
.withColumn("terms", when(col("start_date") <= col("end_date")), col("sarter_terms")).otherwise(col("exp_terms")) \
这会产生语法错误。
我还更新了以下内容:
.withColumn("terms", when(col("start_date").leq(col("end_date"))), col("sarter_terms")).otherwise(col("exp_terms")) \
但是这会产生一个Python错误,列是不可调用的。
如何创建一个新的列,根据datecomparator是否有效来动态调整。
.withColumn("terms", when(col("start_date") <= col("end_date")), col("sarter_terms")).otherwise(col("exp_terms"))
把它改成
.withColumn("terms", when( col("start_date") <= col("end_date") , col("sarter_terms") ).otherwise(col("exp_terms")) )
始终扇出圆括号以正确测量闭合圆括号是否在适当的位置