I have a dataframe where some of the SongIds are repeated. I would like to extract those rows which have the repetition. Any idea how? Tried:
dfB[dfB.SongId.duplicated()]
But didn't work well.
This is an example of my dataframe. SongId 0, 10 and 16 are repeated in this example:
try this,
df=pd.DataFrame({"Song ID":[0,0,1,3,1,4,5],'ArtistID':[12,13,34,1,21,43,22]})
print df[df.duplicated(subset=['Song ID'],keep=False)]
Output:
Song ID value
0 0 12
1 0 13
2 1 34
4 1 21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With