Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KeyError when merging
#3
That worked. Thanks.

Strange, because the original code example I was basing it on indicated that the join fields were implicit from the original dfs as they would be in SQL, and would not have to be explicitly listed in the function.

df_merged = pd.merge(df_hown[['dt', 'hown_rt']],
                 df_vcy[['dt', 'vcy_rt']],
                 on=['dt','dt'])

df_merged.head()
Out[140]: 
          dt  hown_rt  vcy_rt
0 1980-01-01     65.5     5.2
1 1980-04-01     65.6     5.6
2 1980-07-01     65.6     5.7
3 1980-10-01     65.6     5.0
4 1981-01-01     65.6     5.2
Reply


Messages In This Thread
KeyError when merging - by kbrummert - Jan-20-2019, 03:14 AM
RE: KeyError when merging - by stullis - Jan-20-2019, 03:30 AM
RE: KeyError when merging - by kbrummert - Jan-20-2019, 03:43 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020