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
Dataframe Light()在spark中有什么用途?下面两段代码返回相同的输出,使用lit()有什么好处_Dataframe_Apache Spark_Pyspark - Fatal编程技术网

Dataframe Light()在spark中有什么用途?下面两段代码返回相同的输出,使用lit()有什么好处

Dataframe Light()在spark中有什么用途?下面两段代码返回相同的输出,使用lit()有什么好处,dataframe,apache-spark,pyspark,Dataframe,Apache Spark,Pyspark,我这里有两段代码 gooddata = gooddata.withColumn("Priority",when(gooddata.years_left < 5 & (gooddata.Years_left >= 0),lit("CRITICAL"))).fillna("LOW").show(5) gooddata=gooddata.withColumn("Priority",when((gooddata.Years_left < 5) & (gooddata.

我这里有两段代码

gooddata = gooddata.withColumn("Priority",when(gooddata.years_left < 5 & (gooddata.Years_left >= 0),lit("CRITICAL"))).fillna("LOW").show(5)

gooddata=gooddata.withColumn("Priority",when((gooddata.Years_left < 5) & (gooddata.Years_left >= 0),"CRITICAL").otherwise("LOW")).show(5)

对于spark和pyspark:

某些语句中的文字 与空值比较 获取dataframe列的名称而不是dataframe列的内容 例如

问题:


这回答了你的问题吗?
val nonNulls = df.columns.map(x => when(col(x).isNotNull, concat(lit(","), lit(x))).otherwise(",")).reduce(concat(_, _))
val df2 = df.select(col("EmpId"),col("Salary"),lit("1").as("lit_value1"))