I am trying to merge tables based on a key that is common to them using pandas and I am constantly getting the error :
KeyError: 'Host Key of Allocated Locations'
Table one has data: highlighted value is the 'Host Key of Allocated Locations'. Also, it has duplicate values which I want to have as they will be needed in further analysis.
Table 2: highlighted value is the PK key
df3 = pd.merge(timetable_2020_df, joined_uom_space_df, on='Host Key of Allocated Locations', how='left')
I tried but I cannot understand what the issue is.
duplicate data is :
The on
keyword only works when you have the same named column in both dataframes. Your right
dataframe does not have the 'Host...' column, hence a keyerror is being raised.
You will need to use left_on
and right_on
keywords to specify the joining columns in your left and right dataframes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.