-1

I have two data frames where one looks like this and is called top_10_unique_artists:

df1

and one that looks like this called artists: df2

I am trying to do an inner join based on the artistID by saying

import pandas as pd
top_10_unique_users.join(artists, on=top_10_unique_users.artistID)

however, when I do that the inner join is clearly not working properly because it is joining different ID's together rather than finding the artists in the artist table with the same ID as shown below:

df3

Banani720
  • 159
  • 3
  • 17
  • @cs95 no it doesn't answer the question the person who answered the question answered the question I was digging for at least 30 minutes before asking the question because I didn't find the specific use case I was looking for, – Banani720 Mar 10 '20 at 04:00
  • If that didn't answer your question, you didn't read far enough. Look for left outer join – cs95 Mar 10 '20 at 04:29

1 Answers1

0

You can use merge function, this way you can specify different column names in the two dataframes

import pandas as pd
pd.merge(top_10_unique_users,artists, how='left', left_on = 'artistID', right_on='id')

I cannot test the code as you only provided screenshots and not actual code but that should work.

fmarm
  • 4,209
  • 1
  • 17
  • 29
  • yeah I figured I'd just share what I could because some of these data frames are big csv's how does merge and join differ tho out of curiosity – Banani720 Mar 10 '20 at 03:12
  • `join` uses index to join by default, you have more options available with `merge` – fmarm Mar 10 '20 at 03:17