I have a dataframe that contains information about movies. It has a column called genre that contains a list of genres to which it belongs. for example
df['genre'] ## returns 0 ['comedy', 'sci-fi'] 1 ['action', 'romance', 'comedy'] 2 ['documentary'] 3 ['crime','horror'] ...
I want to know how I can request df, so it returns a cerain movie?
For example, something might like df['genre'].contains('comedy') returns 0, 1.
I know for a list, I can do something like
'comedy' in ['comedy', 'sci-fi']
but in pandas I did not find something similar, the only thing I know is df['genre'].str.contains() , but it does not work for a list type.
python pandas
cqcn1991
source share