熊猫合并无列选项

时间:2018-12-24 09:35:17

标签: python pandas merge

有一个名为release的数据框

release = pd.read_csv('release_dates.csv', index_col=None)
release.head()

然后结果

   title year country date
0 #73, Shaanthi Nivaasa 2007 India 2007-06-15
1 #Beings 2015 Romania 2015-01-29
2 #Declimax 2018 Netherlands 2018-01-21
3 #Ewankosau saranghaeyo 2015 Philippines 2015-01-21
4 #Horror 2015 USA 2015-11-20

我们创建一个名为c_amelia的新数据框以查看特定的

c_amelia = casts[ casts['title'] == 'Amelia']
c_amelia.head()

      title year name type character n
5767 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0
23319 Amelia 2009 Jeremy Akerman actor Sherif

运行合并时,结果是

c_amelia.merge(release).head()

   title year name type character n country date
0 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0 Canada 2009-10-23
1 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0 USA 2009-10-23
2 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0 Australia 2009-11-12
3 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0 Singapore 2009-11-12
4 Amelia 2009 Aaron Abrams actor Slim Gordon 8.0 Ireland 2009-11-13

我想问一下如何理解此合并命令? 当我们要加入SQL时,我们需要指定列名A =列名B。 但是此merge命令不包含任何列名,所以熊猫如何知道要合并的内容以及方式?

我找不到任何其他资源的答案。

0 个答案:

没有答案