0

I am using Kaggle Spotify 1921-2020 (data.csv) dataset which contain a column 'artists' which is of object datatype, I tried to perform conditional extraction on the data-frame spotify[spotify['artists'] == 'Dennis Day'] it outputs no row it happens no matter what value I put in. I tried to change its data type to str spotify.artists.apply(str) but still, nothing happened and its datatype is still showing as object

What I did till now

# previously the value was like
0                                       ['Dennis Day']
1    ['Sergei Rachmaninoff', 'James Levine', 'Berli...


# I remove the square braces
spotify['artists'] = spotify['artists'].apply(lambda x : x[1:-1])

0                                         'Dennis Day'
1    'Sergei Rachmaninoff', 'James Levine', 'Berlin...

# since it was giving no output for any value I checked this
for i in songs.artists.head(10):
    print(f'{i} is present {i in songs.artists}')

# and see what I get

'Dennis Day' is present False
'Sergei Rachmaninoff', 'James Levine', 'Berliner Philharmoniker' is present False
'John McCormack' is present False

# don't get confused if somewhere it is written songs and instead of spotify they are same.

I tried to change Kaggle notebook to jupyterlab but it's same all around so what should I do now

Darkstar Dream
  • 1,649
  • 1
  • 12
  • 23

1 Answers1

0

For the conditional extraction on the data-frame, try using .loc:

spotify.loc[spotify['artists'] == 'Dennis Day']