【发布时间】:2019-02-15 08:07:25
【问题描述】:
我有一个数据框,我想比较它们是否存在于另一个 df 中。
after_h.sample(10, random_state=1)
movie year ratings
108 Mechanic: Resurrection 2016 4.0
206 Warcraft 2016 4.0
106 Max Steel 2016 3.5
107 Me Before You 2016 4.5
我想比较上述电影是否存在于另一个 df 中。
FILM Votes
0 Avengers: Age of Ultron (2015) 4170
1 Cinderella (2015) 950
2 Ant-Man (2015) 3000
3 Do You Believe? (2015) 350
4 Max Steel (2016) 560
我想要这样的东西作为我的最终输出:
FILM votes
0 Max Steel 560
【问题讨论】:
-
如果将复合字符串列 df2['FILM'] 转换为其两个组成列
movie_title (year),则可以与pd.merge()连接
标签: python pandas join string-matching partial