0

I have these two dataframes:

avg_rating

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

data

         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

I would like to merge them based on movieId. My issue is that in the first dataframe, the index is the movieId, while in the second dataframe the movieId is a value. How can I get around this? I just started learning pandas so excuse me if my question is stupid or badly written.

4
  • 1
    Please see the documentation for merge ... it's very clearly spelled out there. Commented Aug 10, 2017 at 15:37
  • 1
    Possible duplicate of Using Merge on a column and Index in Pandas Commented Aug 10, 2017 at 15:40
  • @Ajean - I try no answering clearly dupes, but sometimes it happens :( Commented Aug 10, 2017 at 15:51
  • @jezrael All good, I probably just rolled out on the wrong side of the bed today. There may be a nicer-looking dupe than the one I chose, also, I just picked the first one that showed up. Commented Aug 10, 2017 at 15:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.