Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Withcolumn何时为非空Pyspark_Python_Apache Spark_Pyspark_Apache Spark Sql - Fatal编程技术网

Python Withcolumn何时为非空Pyspark

Python Withcolumn何时为非空Pyspark,python,apache-spark,pyspark,apache-spark-sql,Python,Apache Spark,Pyspark,Apache Spark Sql,我从控制台收到以下错误: TypeError:uz()接受1个位置参数,但给出了2个 以下是使用的代码: import pyspark.sql.functions as f start = '2020-10-20' end = '2021-01-20' country = 'es' spark.conf.set('spark.sql.legacy.timeParserPolicy', 'LEGACY') dim_customers = (spark.table(f'nn_team_{cou

我从控制台收到以下错误:

TypeError:uz()接受1个位置参数,但给出了2个

以下是使用的代码:

import pyspark.sql.functions as f

start = '2020-10-20'
end = '2021-01-20'

country = 'es'
spark.conf.set('spark.sql.legacy.timeParserPolicy', 'LEGACY')

dim_customers = (spark.table(f'nn_team_{country}.dim_customers')
           .select(f.col('customer_id').alias('customers'),
                   f.col('hello_pay_date').alias('hello_pay_date'),                    
                      )
                 .withColumn('HelloPay_user',
                             f.when((f.col('lidl_pay_date').isNotNull(1)).otherwise(0))
           ))


我尝试了()的几种组合,但没有结果。你知道我为什么会出现这个错误吗?

你的语法不正确。您应该在
when
子句中输入1,而不是在
isnotnull

dim_customers = (spark.table(f'nn_team_{country}.dim_customers')
           .select(f.col('customer_id').alias('customers'),
                   f.col('hello_pay_date').alias('hello_pay_date'),                    
                      )
                 .withColumn('HelloPay_user',
                             f.when(f.col('lidl_pay_date').isNotNull(), 1).otherwise(0))
           ))

你能发布完整的堆栈跟踪吗?你好@mck,谢谢你的回答,我尝试了你的解决方案,效果很好。但我有一个问题要问你:为什么当你把.isNotNull()放在()之外时,1必须是“在()之外”?否则它就在()之内.ThanksIt是spark的语法。您可以在中了解它。isnotnull不接受参数。
1
应该是
when
的参数,而不是
isnotnull
。类似地,
0
的参数,否则