0

I have df similar to this made up one:

index1 index2 col1 col2 col1 col2 col1 col2

0      0      2    4    NAN  NAN  NAN  NAN
0      1      NAN  NAN  5    6
1      0      NAN  NAN  NAN  NAN 7     8

I want to get:

index1 index2 col1 col2 

0      0      2    4    
0      1      5    6  
1      0      7    8

maybe it worth mention that the input df of my question is a result of cocncat of many dataframes and I couldn't get rid of the duplications. Every df who been concat is looking like this:

index1 index2 col1
1      0      11 

and it contain more columns but only one row. There are no two dataframes with conflict over a data cell in the result dataframe I wish to create.

Thanks

Eran David
  • 29
  • 3
  • 1
    Try `df.stack()` Should work according to [This other similar stackoverflow post.](https://stackoverflow.com/questions/50662613/merge-two-columns-into-one-within-the-same-data-frame-in-pandas-python) – Campiotti Jan 14 '20 at 13:04
  • @campiotti It solve my problem, thanks for the reference! – Eran David Jan 14 '20 at 14:13

0 Answers0