Reputation: 61
I have two data frames, one looks like: And another that looks like:
I'm getting an error when I try to merge the two dataframes using pd.merge The error is "value error: you are trying to merge on datetime64[ns] and int64 columns". How do I get around this problem?
Upvotes: 0
Views: 62
Reputation: 323226
You can do
df['Date']=pd.to_datetime(df['Date'])
df=df.merge(df1,how='left')
Upvotes: 1
Reputation: 623
You'd need to have the same dtype for both columns. So convert the first date to a year, and the merge should then be fine.
df['Date'] = df['Date'].apply(lambda x: x.year)
Upvotes: 1