0

How do I combine these 2 columns together? Ie, I want to remove the NAN and shift Column 1(a series) into Column 0 (a dataframe)

                                                     0              1
A    *aasvfasfdb                                                  NaN
1                                                  NaN   456,0.002121
2                                                  NaN   567,0.005298
3                                                  NaN   345,0.006192
4                                                  NaN   345,0.004532

I have tried different entries of the drop method ie, drop(columns=0, inplace=False) but they either replace one column or the other.

Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58
shoggananna
  • 545
  • 5
  • 9

1 Answers1

1

Use df.combine_first():

In [198]: df['0'].combine_first(df['1'])
Out[198]: 
0     *aasvfasfdb
1    456,0.002121
2    567,0.005298
3    345,0.006192
4    345,0.004532
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58