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"))
)

Here is what the above code is Doing:
1. We’re using the withColumn() method to add a new column to the DataFrame.
2. We’re using the when() method to specify the condition that we want to check.
3. We’re using the otherwise() method to specify the value that we want to use if the condition is not met.