Search
 
SCRIPT & CODE EXAMPLE
 

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

PREVIOUS NEXT
Code Example
Python :: python render_template 
Python :: renaming column in dataframe pandas 
Python :: python raise and exit 
Python :: packing and unpacking in python 
Python :: how to define a constant in python 
Python :: python conditional operator one line 
Python :: python path from string 
Python :: tf dropout 
Python :: python remove empty list 
Python :: input age in python 
Python :: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 43350 
Python :: Write a Python function to check whether a number is in a given range. 
Python :: how to play audio in python 
Python :: python3 add dictionary to dictionary 
Python :: python iterate backwards through list 
Python :: image no showing in django 
Python :: No package python37 available. 
Python :: how to import axes3d 
Python :: replace all nan values in dataframe 
Python :: how to find the location of a character in a string in python 
Python :: get guild by id discord.py 
Python :: integer colomn to datetime pandas python 
Python :: sort rows in csv file using python pandas 
Python :: axes color python 
Python :: np to tuple 
Python :: calculate age python 
Python :: unicodedecodeerror file read 
Python :: python check if number is in range 
Python :: how to do a square root in python 
Python :: python fillna with mode 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =