0

I have the following python pandas data frame:

df = pd.DataFrame({'a':[0,2,0,0], 'b':[0,1,2,0], 'c':[1,1,5,8]})

I would like to have another column storing the name of the first columns non-zero

   a  b  c  result    
0  0  0  1  c
1  2  1  1  a
2  0  2  5  b
3  0  0  8  c
Gregor D
  • 121
  • 2

0 Answers0