I have a pandas dataframe that has reviews in it an I want to search for a specific word in all of the columns.
df["Summary"].str.lower().str.contains("great", na=False)
This gives the outcome as true or false, but I want to create a new column with 1 or 0 written in the corresponding rows.
For example if the review has 'great' in it it should give as 1, not 2. I tried this:
if df["Summary"].str.lower().str.contains("great", na=False) == True:
df["Great"] = '1'
else:
df["Great"] = '0'
It gives this error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). How can I solve this?