I am working with pyspark below is my dataframe
col_list | col_1| col_2 |...|col_n
col_1,col2 | x | y |...|n
col_2,col_n| a | b |...|z
I want concat columns which are present in my col_list column values
Expected DF:
col_list | col_1| col_2 |...|col_n | concat_cols
col_1,col2 | x | y |...|n | [col_1:x,col_2:y]
col_2,col_n| a | b |...|z | [col_2:b,col_n:z]
Trying with below approaches:
Creating udf to pass col_list and create expression to create array col like array(df['col_1'],df['col_2']) , but this will create column with string , not sure how to execute expression
Using create map passing col_list in loop and create column, need to check on this.