0

I have two pandas DataFrames df1 and df2:

df1:      df2:

   A         A

1 10      2 21
2 20      3 31
5 50      4 41
6 60      5 51

and want to merge both DataFrames to the most complete one based on their indexes. The result should be the following:

df_full

   A

1 10
2 20
3 31
4 41
5 50
6 60
Dmitry Mottl
  • 842
  • 10
  • 17
  • Isn't this a duplicate of [this](https://stackoverflow.com/questions/12850345/how-do-i-combine-two-data-frames) answer – Erfan Mar 27 '20 at 14:21

1 Answers1

3

You have combine_first for this:

df1.combine_first(df2).astype(int)

    col1
1    10
2    20
3    31
4    41
5    50
6    60
yatu
  • 86,083
  • 12
  • 84
  • 139