I have a pyspark data frame which has string ,int and array type columns. I am trying to run a for loop for all columns to check if their is any array type column and convert it to string.
The output in the pyspark data frame should then hold the int,string columns.
I have below code however it fails with below error. Any suggestions to fix this error
df2 = df.select([df.withColumn(c,F.concat_ws(",",col(c))).alias(c) if dict(df.dtypes)[c] in 'array<string>' else F.col(c) for c in df.columns])
Error : For column literals, use 'lit', 'array', 'struct' or 'create_map' function.