I have a dataset in a .csv which I imported into a DataFrame using pandas, organized in the following manner (obviously not real numbers):
A B C D E F
0 20 4 24 8 28
1 21 5 25 NA NA
NA NA 6 26 10 30
3 23 NA NA 11 31
What I want to achieve is to save the data in two extra columns G and H in the same DataFrame so I get the following:
A B C D E F G H
0 20
1 21
... ...
11 31
Where I would like to keep the same index for all data (so B belongs to A, D to C, F to E etc.). As you can see, the original dataset has some missing values, so I would also like to skip these if they are in there.
Now, I have looked into pandas append and concat, however I do not see how I can achieve what I wanted, especially with skipping the empty values (presumbly via data.dropna()
or some other function?).