Below is a code snipped which uses multiple when clauses (it's just a couple but it could well be 10s or more):
df = (df.withColumn('tmp_col',
when(df.some_col.isin(val_list),"val_1")
.when(df.some_col.isin(val_list),"val_2")
.otherwise(''))
When we have multiple such when conditions which can be easily be written in a loop to reduce code lines, should I do so or will that significantly affect performance. Or is there perhaps another better/efficient way to do so?