Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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"))
)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #replace #row #pyspark #dataframe
ADD COMMENT
Topic
Name
9+9 =