I have dataset of Netflix shows. I want to filter the records based on:
data.loc[(data.type=='Movie') & (data.genre=='Action') & ('taxi' in str(data.description))]
There are no syntax errors in the above command however it`s not working as per my assumptions.
The condition that is causing the problem is:
('taxi' in str(data.description)
CodePudding user response:
It seems that you want Series.str.contains
data.loc[(data.type == 'Movie') & (data.genre == 'Action') & data.description.str.contains('taxi')]
To understand why your code doesn't run check first the output of print(str(data.description))
. What does it produce? What is the output of print('taxi' in str(data.description))
? Do you understand what is happening?
CodePudding user response:
Try this:
data.loc[(data.type=='Movie') & (data.genre=='Action') & (data.description.str.contains('taxi')]