I have a dataframe with a few columns. Now I want to derive a new column from 2 other columns:
from pyspark.sql import functions as F new_df = df.withColumn
Use parentheses to enforce the desired operator precedence:
F.when( (df["col-1"]>0.0) & (df["col-2"]>0.0), 1).otherwise(0)