This code isn't working in Jupyter IDE. I can't find my mistake. Please help.
Try the following:
df.loc[df['compound'] > 0,'SentimentType'] = 'Positive'
df.loc[df['compound'] < 0,'SentimentType'] = 'Negative'
df.loc[df['compound'] == 0,'SentimentType'] = 'Neutral'
Instead of retrieving the column through df.compound,
you should do df['compound']
. You can also tell from the error message that you received that df.compound
is a method name and not the column that you are looking for.