Pandas:连接两个具有不同列名的数据帧

时间:2015-10-31 17:59:30

标签: python pandas

我有两个数据框

df1 = 
    actorID         actorName
0   annie_potts     Annie Potts
1   bill_farmer     Bill Farmer
2   don_rickles     Don Rickles
3   erik_von_detten Erik von Detten
4   greg-berg       Greg Berg

df2 = 
    directorID      directorName
0   john_lasseter   John Lasseter
1   joe_johnston    Joe Johnston
2   donald_petrie   Donald Petrie
3   forest_whitaker Forest Whitaker
4   charles_shyer   Charles Shyer

我理想的是这两个数据框的连接,例如pd.concat((df1, df2))

    actorID-directorID   actorName-directorName
0   annie_potts          Annie Potts
1   bill_farmer          Bill Farmer
2   don_rickles          Don Rickles
3   erik_von_detten      Erik von Detten
4   greg-berg            Greg Berg
5   john_lasseter        John Lasseter
6   joe_johnston         Joe Johnston
7   donald_petrie        Donald Petrie
8   forest_whitaker      Forest Whitaker
9   charles_shyer        Charles Shyer

但是我希望有一种简单的方法来指定我想要加入df1.actorNamedf2.directorName以及actorID / directorID。我怎么能这样做?

0 个答案:

没有答案