Skip to content

Instantly share code, notes, and snippets.

@devamitranjan
Last active December 15, 2020 17:36
Show Gist options
  • Save devamitranjan/5ecfe4d3ad1911ebd7f1eaad650d8d8f to your computer and use it in GitHub Desktop.
Save devamitranjan/5ecfe4d3ad1911ebd7f1eaad650d8d8f to your computer and use it in GitHub Desktop.
from textblob.blob import TextBlob
def find_polarity_of_single_comment(text):
return TextBlob(text).sentiment.polarity
def find_polarity_of_every_comment(df):
df['Polarity'] = df['Comments'].apply(find_polarity_of_single_comment)
return df
df = find_polarity_of_every_comment(df)
df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment