When I merge two dataframes (with different number of rows) on 'Date' as below I get the Error ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
. I looked at the answer here and converted dates in both my dataframes to str
but I still get the error. I tried to convert the Dates
to int
as well, but that results in another error ValueError: invalid literal for int() with base 10: '1919-01-01'
. I'm not too sure how to solve this.
df_trial.columns = ['Date', df_trial.columns[1]]
df_trial['Date'] = df_trial['Date'].astype(str)
df_fly.columns = ['Date', df_fly.columns[1]]
df_fly['Date'] = df_fly['Date'].astype(str)
df_trial = df_trial.merge(df_fly, left_on='Date', right_index=True).reset_index() ##Error
df_fly=
Date AGG
0 2003-10-01 -0.007216
1 2003-11-01 -0.000123
2 2003-12-01 0.001782
3 2004-01-01 0.009108
df_trial=
Date AAA
0 1919-01-01 4.09
1 1919-02-01 1.45
2 1919-03-01 5.21