0

So I am creating an Recommendation Machine Learning modal and above are the data set,

name is name of the song, song is the mp3 file, likes are the song has got,

   id        name         song   likes   
0    1        eeee    song.mp3      70     
1    2        aaaa    song.mp3      59    
2    3    any song    song.mp3       7    
3    6   australia    song.mp3      99   
4    7       qwert    song.mp3       0   
5    9      summer    song.mp3      10    

Here the song_id is the id of the song in above data set and performer is the id of the artist who has performed in the song, one song can have more than 1 artist as you can see song with id 1 has 3 artist id's associated with it named 9,10,11

    song_id  performer
0         1          9
1         1         10
2         1         11
3         2          9
4         2         10
5         2         11
6         2          5
7         3          9
8         3         10
9         6          5
10        6          9
11        6         10
12        6         11
13        6         16
14        7          5
15        7          9
16        7         10
17        7         11
18        7         16
19        9         16
20        9         17

How can I join both datasets as one dataset? How can I display this OneToMany relation (1 song - many performers) in my dataframe? as you can see there are 6 songs and 21 song and performer relation.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Pranay Ambre
  • 87
  • 1
  • 8
  • 2
    This is a standard `pandas` question about how to join/merge two dataframes, and has nothing to do with `machine-learning` (or K-means) - kindly do not spam irrelevant tags (removed). – desertnaut Jun 24 '20 at 22:28

1 Answers1

0

Please see if merge works -

df2.merge(df1)

click for result image

Emma
  • 27,428
  • 11
  • 44
  • 69