python使用来自df2的键/df1的索引进行合并

2024-09-21 03:28:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我有两个数据帧:

平均评分

movieId      rating
  1         3.921240
  2         3.211977
  3         3.151040
  4         2.861393
  5         3.064592

数据

         movieId      title                                 year
  0           1       Toy Story (1995)                      1995
  1           2       Jumanji (1995)                        1995
  2           3       Grumpier Old Men (1995)               1995
  3           4       Waiting to Exhale (1995)              1995
  4           5       Father of the Bride Part II (1995)    1995

我想基于movieId合并它们。我的问题是,在第一个数据帧中,索引是movieId,而在第二个数据帧中,movieId是一个值。 我怎么才能避开这个? 我刚开始学熊猫,所以请原谅我的问题是愚蠢的或写得不好。你知道吗


Tags: to数据title评分yearoldwaitingrating

热门问题