Reputation: 12341
Typically we can simply run df1.join(df2)
if the dates are perfectly aligned. However in my data set I have a slight mismatch with the index.
In df1
the pandas.tseries.index.DatetimeIndex
format is 2004-07-07 20:00:00, 2004-07-08 20:00:00...
and in df2
the pandas.tseries.index.DatetimeIndex
format is 2004-07-07, 2004-07-08,...
I want to ignore the hours minutes and seconds and join these two data frames
. No error is thrown but NaN values will appear for columns from df2
on 2004-07-08 20:00:00
. How can I join these two data frames?
Upvotes: 0
Views: 251
Reputation: 147
I think the simplest solution is to reformat the datetime columns of one or both of your dataframes. Perhaps you could remove the time from your first dataframe, assuming the time is not important to you. Here's a post which uses normalize
to achieve this.
Upvotes: 1