Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pyspark when otherwise multiple conditions

df5.withColumn("new_column", when(col("code") == "a" | col("code") == "d", "A")
      .when(col("code") == "b" & col("amt") == "4", "B")
      .otherwise("A1")).show()
Source by sparkbyexamples.com #
 
PREVIOUS NEXT
Tagged: #pyspark #multiple #conditions
ADD COMMENT
Topic
Name
6+2 =