Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to replace a row value in pyspark dataframe

from pyspark.sql.functions import col, when

valueWhenTrue = None  # for example

df.withColumn(
    "existingColumnToUpdate",
    when(
        col("userid") == 22650984,
        valueWhenTrue
    ).otherwise(col("existingColumnToUpdate"))
)
Comment

PREVIOUS NEXT
Code Example
Python :: how to receive user input in python 
Python :: how to fix geometry of a window in tkinter 
Python :: python create random matrix 
Python :: tkinter draw squaer 
Python :: python poner en mayusculas 
Python :: binary number in python 32 bit 
Python :: prime number program in python print 1 to 100 
Python :: create spark dataframe in python 
Python :: python pandas cumulative return 
Python :: python find closest value in list to zero 
Python :: spacy matcher syntax 
Python :: matplotlib boxplot remove outliers 
Python :: python if else variable assignment 
Python :: python system of equations 
Python :: add percentage column pandas 
Python :: how to download youtube playlist using python 
Python :: pyhton turtle kill 
Python :: pandas groupby get all but first row 
Python :: how to convert string to date object in python 
Python :: pygame window 
Python :: windows alert python 
Python :: bar plot fix lenthgy labels matplot 
Python :: playsound module in python 
Python :: python list distinct 
Python :: Install Basemap on Python 
Python :: how to check python version in cmd 
Python :: micropython network 
Python :: get rid of n in string python 
Python :: python print string separated by comma 
Python :: pandas load dataframe without header 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =