Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sid = SIA()
f_data['sentiments'] = f_data['text'].apply(lambda x: sid.polarity_scores(' '.join(re.findall(r'\w+',x.lower()))))
f_data['Positive Sentiment'] = f_data['sentiments'].apply(lambda x: x['pos']+1*(10**-6))
f_data['Neutral Sentiment'] = f_data['sentiments'].apply(lambda x: x['neu']+1*(10**-6))
f_data['Negative Sentiment'] = f_data['sentiments'].apply(lambda x: x['neg']+1*(10**-6))
f_data.drop(columns=['sentiments'],inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment