Exercise: sentiment analysis

This exercise is based on the idea of Brit Cava, who used the Makeover Monday data from the top 100 song lyrics in order to try out the Tableau-Python integration. You can find the blog post here: https://www.tableau.com/about/blog/2016/12/using-python-sentiment-analysis-tableau-63606. Let's reproduce it with another dataset:

  1. Navigate to the Sentiment tab in the workbook associated with the chapter.
  2. Connect to the Lord of the Rings data source.
  3. Connect Tableau to Python.
  4. Create a Sentiment Scores calculated field:
SCRIPT_REAL("from nltk.sentiment import SentimentIntensityAnalyzertext = _arg1scores = []sid = SentimentIntensityAnalyzer()for word in text: ss = sid.polarity_scores(word) scores.append(ss['compound']) ...

Get Mastering Tableau 2019.1 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.