how to replace a row value in pyspark dataframe

Solutions on MaxInterview for how to replace a row value in pyspark dataframe by the best coders in the world

showing results for - "how to replace a row value in pyspark dataframe"
Sofia
29 Aug 2017
1from pyspark.sql.functions import col, when
2
3valueWhenTrue = None  # for example
4
5df.withColumn(
6    "existingColumnToUpdate",
7    when(
8        col("userid") == 22650984,
9        valueWhenTrue
10    ).otherwise(col("existingColumnToUpdate"))
11)
12