I have some 5 columns to be added to the dataframe. (A - E) The values for these columns are stored in (a - e) variables.
Instead of using
df.withColumn("A", a).withColumn("B", b).withColumn..... etc
Can we do this with a udf?
Currently I have named function :
def add_col(df_name,newCol,value):
df = df_name
df = df.withColumn(newCol, value)
return df
But I am not able to understand how to convert it to UDF and use it. Please help.