I have a dataframe df which contains movies data.
.
I want to create a new column in df called "drama_movie" which contains the value True for the movies that are Dramas and False for if they are not.
I tried it with following code:
df["drama_movie"]=df['listed_in'].isin(["Dramas"])
-> but I receive everything as False in the column drama_movie.
When I try the following code:
df["drama_movie"]=df.apply(lambda x: x['listed_in'] in x['Dramas'], axis=1)
-> I receive a key error "Dramas"
What works is this code:
df["drama_movie"] = df['listed_in'].str.contains('Dramas', case=False, na=False)
-> But I need to use pythons in operator. I'm somehow stuck with it. Any suggestions? Thank you for your help