简体   繁体   English

数据框连接

[英]Data Frame Join

I'm using Jupyter notebooks to join two data frames together and I'm getting the following error.我正在使用 Jupyter 笔记本将两个数据框连接在一起,但出现以下错误。 Does anyone know the right way to write this?有谁知道写这个的正确方法?

ValueError: Can only compare identically-labeled Series objects ValueError:只能比较标签相同的系列对象

data_set = git_author.join(repo_team, on=git_author.project==repo_team.gitProject)

You error ValueError: Can only compare identically-labeled Series objects comes from the fact there is not a column with the same label in both data frames that you can use with a key.您的错误ValueError: Can only compare identically-labeled Series objects是因为在两个数据帧中没有一个列具有相同的 label ,您可以使用一个键。 Then, I suggest using:然后,我建议使用:

data_set = git_author.merge(repo_team, right_on = "project", left_on = "gitProject")

Additionally, you can specify the how parameter to tell merge whether you want to do an inner join, outer join, left join or right join.此外,您可以指定how参数来告诉合并您是要进行内连接、外连接、左连接还是右连接。

This way, you can specify the label of the column to be used as a key on the merge, even though that label is different for both data frames.这样,您可以指定要用作合并键的列的 label,即使两个数据帧的 label 不同。

NB: since I don't have your data, it has not been tested.注意:由于我没有您的数据,因此尚未经过测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM