Skip to content Skip to sidebar Skip to footer

Assign Small Dataframe To Large Dataframe By Row Indices

I am trying to assign a small dataframe to a large dataframe, both have the same columns. I couldn't find a duplicate on this. Pandas version 1.1.4 which I can't upgrade right now

Solution 1:

you can try values attribute or to_numpy() method:

df1.iloc[3:3+len(df2)]=df2.values#OR#df1.iloc[3:3+len(df2)]=df2.to_numpy()

Update:

other way:

df1.iloc[3:3+len(df2)]=df2.set_index(df1.iloc[3:3+len(df2)].index)

output of df1:

a00112230415263748899

Post a Comment for "Assign Small Dataframe To Large Dataframe By Row Indices"