Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pyspark case when

# PYSPARK DATAFRAME API

from pyspark.sql.functions import when

df.select("*",when(df.value == 1, 'one'
            ).when(df.value == 2, 'two'
            ).otherwise('other'))
 
PREVIOUS NEXT
Tagged: #pyspark #case
ADD COMMENT
Topic
Name
2+9 =