0

The first dataframe(df1) is similar to this:

Result A B C
2021-12-31 False True True
2022-01-01 False False True
2022-01-02 False True False
2022-01-03 True False True

df2 is an updated version of df1, the date data are new and the column names may be increased, which is similar to this:

Result A B C D
2022-01-04 False False True True
2022-01-05 True False True True
2022-01-06 False True False True
2022-01-07 False False True True

I want to integrate two databases, but I don't know how to do it。 I want to get a result similar to the following:

Result A B C D
2021-12-31 False True True NaN
2022-01-01 False False True NaN
2022-01-02 False True False NaN
2022-01-03 True False True NaN
2022-01-04 False False True True
2022-01-05 True False True True
2022-01-06 False True False True
2022-01-07 False False True True

Thank you very much!

xyww
  • 17
  • 3
  • 1
    Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – Amin S Feb 06 '23 at 00:44

1 Answers1

0

Use the concatenate function while ignoring indexes

df_new = pd.concat([df1, df2], ignore_index=True)

Any missing values will be 'NaN'.

A-T
  • 342
  • 2
  • 14