I am trying to use if statement and str.contains() to generate a label which I can apply to a new column, but I am getting Attribute Error .....
AttributeError: 'str' object has no attribute 'str'
How Can I incorporate str.contains() in the if statement and create a column?
This is a simple if statement I have tried:
def f(row):
if(row['ContentTitle'] == 'Mr Bean'):
return 'English Movie'
if(row['ContentTitle'] == 'Jurassic Park'):
return 'English'
if(row['ContentTitle'] == 'Okwonko'):
return 'Nigeria Movie'
if(row['ContentTitle'].str.contains('Mama Ntilie')):
return 'Swahili Movie'
else:
return 'Others'
I have tried to use str.contain ('Mama Ntilie')
because this is a series and it has multiple seasons and Episode, labeling each one will be tiresome
Streamers_Data_Sample['Content_Watched'] = Streamers_Data_Sample.apply(f, axis = 1)