I have a dataframe like this:
col1 col2 col3 Other
====================================
NULL 1 2 A
3 4 5 B
NULL NULL NULL C
and I would like to get as result the following one with this rules:
- For each row find the first non-NULL value and set its value in
FirstValueand set its column name inColName - If in a row all values are NULL,
FirstValueandColNameare set to NULL - keep
Othercolumn
Expected result:
FirstValue ColName Other
====================================
1 col2 A
3 col1 B
NULL NULL C