I have a df:
c1 c2 c3
A None A
B A None
C None None
None None None
I am trying to add a column which contains the column names 'c1-c3' if the respective columns are not null
So the resulting df should be:
c1 c2 c3 c4
A None A c1|c3
B A None c1|c2
C None None c1
None None None None
Constructor
data = {'c1': ['A', 'B', 'C', None],
'c2': [None, 'A', None, None],
'c3:':['A',None,None,None]}
df = pd.DataFrame(data)