Home > Software design >  Merge two Panda rows
Merge two Panda rows

Time:08-15

I need help getting two rows in the same datafram merged/joined.

enter image description here

The first table is the df that I have right now The second one is the one that I would like to have

I need to combine Jim and Bill. I don't want to overwrite values in either tables. I just want to update NaN values in the row (Bill) with the values with row(Jim) e.g city

There are about 20 columns that I need updating because of that I cannot just update the Bill/City cell

Thanks

CodePudding user response:

You can try

df.loc['Bill'] = df.loc['Bill'].fillna(df.loc['Jim'])
# or
df.loc['Bill'].fillna(df.loc['Jim'], inplace=True)
  • Related