samedi 19 juin 2021

How can I calculate the polarity based on an if-condition in python?

I try to calculate the polarity of the column "Review Gast" based on the if-condition that the value in the column "Food" needs to be "True". This is my code:

from textblob import TextBlob
if reviews_english['Food'] == True:
    reviews_english['Polarity Food'] = reviews_english['Review Gast'].map(lambda text: TextBlob(text).sentiment.polarity)

However the following error occurs:

"ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire