ur has 2 columns and 20 rows and looks like this:
DATE         UNRATE       
1997-12-31  4.941667
1998-12-31  4.500000
1999-12-31  4.216667
atddf also has 2 cols and 20 rows and looks like this:
              attendance
yearID                  
1997-01-01  2.256025e+06
1998-01-01  2.353372e+06
1999-01-01  2.337979e+06
I want to find the correlation between the attendance and UNRATE columns but believe I need to join or merge the dataframes first. How do I join/merge on the yearID/DATE columns so the years match up?
I have tried these techniques and get the following errors:
join = ur.merge(atd_df, on="DATE")
KeyError: 'DATE'
join = ur.merge(atd_df, on="yearID")
KeyError: 'yearID'
res = pd.merge(urdf.assign(grouper=urdf['DATE'].dt.to_period('Y')),
               atddf.assign(grouper=atddf['yearID'].dt.to_period('Y')),
               how='left', on='grouper')
KeyError: 'DATE'
