I want to create a pandas series based on the values in the 'overall' series.
if relevant.overall <= 2:
relevant['Sentiment'] = 'Negative'
elif relevant.overall == 3:
relevant['Sentiment'] = 'Neutral'
else: #Score of 4 or 5
relevant['Sentiment'] = 'Positive'
This was my code for which I got the error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). Then I checked on some previously asked question and tried the accepted answer on this: Why am I getting ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Sentiment = []
for i, row in relevant.iterrows():
if row.overall <= 2:
Sentiment.append('Negative')
elif row.overall == 3:
Sentiment.append('Neutral')
else: #Score of 4 or 5
Sentiment.append('Positive')
This is my code now for which I'm getting, 'str' object has no attribute 'append'.