Skip to content

Instantly share code, notes, and snippets.

@lievcin
Created February 12, 2018 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lievcin/57a676c3add9e1e7e10f74bf3f29b797 to your computer and use it in GitHub Desktop.
Save lievcin/57a676c3add9e1e7e10f74bf3f29b797 to your computer and use it in GitHub Desktop.
def get_sent(rating):
if rating < 3:
sent = 'negative'
elif rating > 3:
sent = 'positive'
else:
sent = 'mweh'
return sent
data['sentiment'] = data.apply(lambda row: get_sent(row['rating']), axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment