1

Assuming that I have a self-created data set like this:

data = pd.DataFrame([['A','B'],[21,22],['B','C'],[25,26]], columns=['a1','a2'])
a1  a2
A   B
1   None
B   C
2   None

then I use the data.dropna function to separate the rows of text for data processing in excel:

dropdf=data.dropna(axis=0, subset=['a2'])
a1  a2
A   B
B   C

After processing I have an extra column called 'a3' like this

a1  a2  a3
A   B   C
B   C   D

What I want here is how to copy and paste only these lines back into 'data' and ignore the lines that were drop at 'dropdf' while keeping the line order.

Dataframe that i want to be:

a1  a2   a3
A   B    C
1   None None
B   C    D
2   None None

Is there any way to paste from a data only the same columns

petezurich
  • 9,280
  • 9
  • 43
  • 57
  • Your examples don't really make sense, the provided output of your commands is not what the commands are doing, please be clear in the inputs and output and the logic. As of now, it looks like a simple `merge` – mozway Feb 11 '23 at 07:14

0 Answers0