Merge 2 pandas dataframes while keeping the whole spectrum of values

df2 = pd.merge(df, df1, on='Datetime', how='outer')

Adding ‘how=’outer’ to ‘pd.merge()’ will actually do the job!

Here’s a very good comprehensive article about Panda’s Join, Merge and Concatenate.

And by the way, if you would like to fill NA values when merging, just add ‘.fillna(‘0′)’, in this case it will fill NA values with zeroes.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x