I have a dataframe like the following:
List1 List2 List3 List4 List5 List6 List7 List8
0 NaN NaN 1 NaN NaN NaN 1 NaN
1 NaN NaN 1 NaN NaN NaN 1 NaN
2 NaN NaN 1 NaN 1.0 NaN 1 NaN
3 NaN NaN 1 NaN NaN NaN 1 NaN
4 NaN NaN 1 NaN 1.0 NaN 1 NaN
I want to create a new Column called Lists which is an array of all the other columns with a non null value. ie:
Lists
0 ['List3', 'List7']
1 ['List3', 'List7']
2 ['List3', 'List5', 'List7']
3 ['List3', 'List7']
4 ['List3', 'List5', 'List7']
I accomplished this with an iterrows() loop, but it's not performant at all. Would appreciate any ideas here.