Skip to content

Instantly share code, notes, and snippets.

@mmsamiei
Created March 6, 2020 19:20
Show Gist options
  • Save mmsamiei/7845d41d05f59f77379382c080aa194f to your computer and use it in GitHub Desktop.
Save mmsamiei/7845d41d05f59f77379382c080aa194f to your computer and use it in GitHub Desktop.
df['polarity'] = df['Text'].map(lambda text: textblob.TextBlob(text).sentiment.polarity)
df['review_len'] = df['Text'].astype(str).apply(len)
df['word_count'] = df['Text'].apply(lambda x: len(str(x).split()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment