[英]Merging of data columns using pandas
I am trying to merge tables based on a key that is common to them using pandas and I am constantly getting the error :我正在尝试根据使用 Pandas 的常用键合并表,但我不断收到错误消息:
KeyError: 'Host Key of Allocated Locations'
KeyError: '分配位置的主机密钥'
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表2:突出显示的值是PK键
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. on
关键字仅在两个数据框中具有相同命名的列时才有效。 Your right
dataframe does not have the 'Host...' column, hence a keyerror is being raised.您
right
数据框没有“主机...”列,因此会引发关键错误。
You will need to use left_on
and right_on
keywords to specify the joining columns in your left and right dataframes.您将需要使用
left_on
和right_on
关键字来指定左右数据right_on
的连接列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.