Search
 
SCRIPT & CODE EXAMPLE
 

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'))
Comment

PREVIOUS NEXT
Code Example
Python :: change freq of date index in pandas 
Python :: pandas drop column by name 
Python :: ffmpeg python cut video 
Python :: how to rename columns in python 
Python :: python trace table generator 
Python :: unable to open file pygame.mixer 
Python :: python unzip list 
Python :: latency discord.py 
Python :: auto python to exe 
Python :: flask mail 
Python :: selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable 
Python :: calculate vif in python 
Python :: get os environment python 
Python :: python catch sigterm 
Python :: read excel file spyder 
Python :: sort list in python by substring 
Python :: hmac in python 
Python :: check if is the last element in list python 
Python :: df concat 
Python :: python get current time 
Python :: how to use variables in string in python 
Python :: merge dataframe 
Python :: How to install XGBoost package in python 
Python :: parquet to dataframe 
Python :: convert a data frame column values to list 
Python :: python if else one line 
Python :: phone number regex python 
Python :: python remove new line 
Python :: dataframe column data type 
Python :: python find closest lower value in list 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =