26
Jul
How New York Tweets About Food, Part 1
I’ve been meaning to play around with the Twitter API for quite some time now. After warming up by analyzing the relationship between followers, people followed, tweets, and account longevity, I set out to study how New York Tweets about food. So, one week ago, I set up a script that hit Twitter’s search API every minute and pulled down tweets about a variety of foods.
For no particular reason, I chose to study bacon, burgers, kale, pizza, quinoa, spinach, tacos, and tofu. Here’s how often New Yorkers tweeted about these foods across the week:
A number of interesting trends stand out. It’s important to keep in mind, though, that we’re only working with one week’s worth of data. And it was a strange week weather-wise, including several 100-ish degree days and a freak Wednesday afternoon hailstorm.
Caveats aside, Monday was the least popular day of the week to tweet about food; it saw about 6% fewer tweets about food than average. Wednesday was the most popular day, with 11% more tweets than average. Saturday and (strangely) Thursday are the only days with more lunch tweets than dinner tweets. On that note, here’s what an average day looks like:

Here we see in more detail that — for the foods selected, at least — breakfast is the least popular meal to tweet about. But the foods selected impact these results significantly. Even though I pulled down data for eight different foods, pizza accounted for a whopping 50% of the total food-related tweets. Bacon came in second at 10%. Quinoa and tofu, unsurprisingly, represented a paltry 2% of the total tweets collected.

With the exception of bleary-eyed college students, most of us don’t make a breakfast out of pizza, which means that the chart above is skewed toward lunchtime, dinner, and late night dining. The data prove this; of the foods studied, pizza saw the lowest number of tweets during breakfast. The following chart shows the share of tweets about a given food that occurred during each hour of the day:

Interestingly, burger tweets spike around lunchtime, yet don’t last as long into the night as pizza does. Tacos see relatively more late-night tweets than any other food, and are the least popular breakfast food. In general, it’s clear that I’ve chosen a sample of foods that are tilted toward lunch and dinner. For the curious, here are the patterns for each of the healthier foods. All show a similar, dinner-centric pattern:

With a handful of insights in hand, I’m going to tweak the script over the next week. I’m also going to blend in some sentiment analysis, which means we’ll know how people feel about their food in addition to when they’re tweeting about it.
A few quick notes on methodology: here’s an example of the data from the Twitter API. I used “burgers” and “tacos” because the singular comes up with too many tweets related to Taco Bell, Burger King, etc. The singular of “pizza” may have pulled down a lot of Pizza Hut-related tweets, unfortunately, but people really don’t talk about multiple pizzas too often.
Lastly, a lot of non-technical people I talk to are amazed when I explain that it only takes a few lines of code to get data from the Twitter API. For the most part, getting the data really isn’t that hard — the harder part is figuring out what to do with it. While it may read like gibberish to most folks, here are the few lines of PHP code that can process thousands of tweets:

