I have a Spark DataFrame where I am trying to create a new column based upon previous columns, but the tough part for me is that I have compute the value of the column row-wise. For example:
col1 |col2 |col3
1 | 2 | 3
4 | 5 | 0
3 | 1 | 1
So, I want a new column which has name of the column of the expression
max(col1, col2, col3) per row. So, desired output:
col1 |col2 |col3 |col4
1 | 2 | 3 | 'col3'
4 | 5 | 0 | 'col2'
3 | 1 | 1 | 'col1'
Anyway it is possible to do in PySpark?