Answers for "how to replace a row value in pyspark dataframe"

0

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"))
)
Posted by: Guest on May-06-2021

Code answers related to "how to replace a row value in pyspark dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language