Dr Pi
Dr Pi

Reputation: 417

Pandas Merge Dataframe, Keep duplicates consecutive

I'd like to merge dataframes df1 and df2, and preserve the row data in the order of original index value.

df3 is my desired output :

enter image description here

Upvotes: 0

Views: 308

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150785

Use concat:

pd.concat((df1,df2)).sort_index(kind='mergesort').reset_index(drop=True)

Upvotes: 1

Related Questions