I have these two pandas dataframes I created and cleaned from online data, and I was trying to merge them based on their dates, which are all by month. However, the first dataset has its days on the last day of the month, whether the second dataset is based on the first day of the month.
# data1
0 1987-01-01 63.752
1 1987-02-01 64.152
2 1987-03-01 64.488
3 1987-04-01 64.995
# data2
0 1987-01-31 1115.10
1 1987-02-30 1095.63
2 1987-03-30 1036.19
3 1987-04-30 1057.08
I would normally merge them by something like this if I had daily data with a few missing days
data3 = pd.merge(left=data1, left_on='Date', right=data2, right_on='Date')
but in this case they are never matching, even though they are all similar dates.
How would I go about "telling" Pandas to combine the datasets based on dates that are just a few days apart, and name each data by just "month - year"? I don't know where to begin.