pyspark case when or code example
Example: 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'))
# PYSPARK DATAFRAME API
from pyspark.sql.functions import when
df.select("*",when(df.value == 1, 'one'
).when(df.value == 2, 'two'
).otherwise('other'))