Skip to content

Instantly share code, notes, and snippets.

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