Figuring out what Democratic candidates care about

In the wide field of Democratic presidential candidates, who cares about what topics and how do these topics change over time?

natural language processing text analysis topic modeling

Summary

While sentiment analysis is probably the most popular approach to analyzing tweets, sometimes you care more about what's being said as opposed to how it's being said. In this piece from Bloomberg, tweets are semi-automatically categorized and topics are shown to wax and wane over the course of a Democratic candidate's path.

We'll use this to illustrate how to obtain large numbers of tweets, as well as how to use topic modeling and keyword matching to automatically categorize tweets. In the spirit of completeness we'll finish by strong-arming matplotlib into displaying our results as a streamgraph!

Bloomberg piece by Allison McCartney, with assistance from Mira Rojanasakul, Cedric Sam, and edited by Alex Tribou.

Notebooks, Assignments, and Walkthroughs

Downloading all 2019 tweets from Democratic presidential candidates

While you can't use the API to get this many tweets, there is a way around it!

Using topic modeling to analyze presidential candidate tweets

Let's find out if topic modeling will help us uncover patterns inside presidential candidate tweets

Assigning categories to tweets using keyword matching

Using a list of keywords, we'll assign categories to tweets for later analysis

Building streamgraphs from categorized and dated datasets

We'll use pandas and matplotlib to create (somewhat ugly) streamgraphs from categorized Democratic presidential candidate tweets