5 Buzzfeed Headline Numbers That Will Change How You Write

Neal Caren - University of North Carolina, Chapel Hill web twitter scholar

After reading 11 Amazing Outfits Ronald Reagan Rocked today, I started to wonder about the distribution of numbers in Buzzfeed headlines. I wrote up a quick Python script to analyze which numbers were used most frequently based on the last 1,861 article headlines tweeted. The full code and results are below, but:

In [1]:
from __future__ import division
from collections import Counter

import twython 
In [2]:
#You can get your own from http://dev.twitter.com

consumer_key='your_consumer_key'
consumer_secret='your_consumer_secret'
access_token='your_access_token'
access_token_secret='your_access_token_secret'
In [3]:
#authenticate yourself
twitter = twython.Twython(consumer_key, consumer_secret, access_token, access_token_secret)
In [4]:
#get some tweets

headlines = []

last_id = 907718359241744384 # a random large number

#Grab the most recent tweets from the buzzfeed feed, ignoring retweets
for i in range(1,17):
    tweets = twitter.get_user_timeline(screen_name = 'buzzfeed', 
                                       include_rts ='False', 
                                       count = 200 , 
                                       max_id = last_id)
    
    headlines = headlines + [tweet['text'] for tweet in tweets]
    last_id =  tweets[-1]['id'] - 1
In [7]:
for headline in headlines[:15]:
    print headline
@MileyCyrus http://t.co/KCNKIdvLNl
Yesss  RT @MileyCyrus: I want a boyfriend that will wear jean on jean on jean with me http://t.co/36OoXUh4Yq
17 Times In 2013 When Anne Hathaway Made Us Lose Our Faith In Hatmanity 
↪ http://t.co/qeYn6hiaUi http://t.co/gLXVeutP0m
11 Portraits Of Your Favorite Pop Culture Families 
http://t.co/oZulY7zjcs http://t.co/FIU7QEbsN5
Batman/Superman movie has found its Wonder Woman, Gal Gadot 
http://t.co/AKMYm9DfK9 http://t.co/pWHzcajLsW
The 33 DUMBEST things that happened in 2013
↪ http://t.co/y2dAlP3SFK http://t.co/XzoJ2v1E8b
Egg nog: Y/N?
40 Signs You’re Almost 40
http://t.co/MLwridkBvV http://t.co/xrGkwIplUB
LOOK AT THIS CAT http://t.co/bi5qpJJzfc
The 40 Most Awkward Dogs Of 2013
↳ http://t.co/UQZ3GUZ19U http://t.co/PwPdVM6oTX
How are you not following @darth already?
The 39 MOST spectacular @Darth photoshops of 2013
http://t.co/Wwb4DiWFrE
⇒ http://t.co/6TNtzvvPUk
The 19 Greatest Dad Jokes From Rick Grimes
http://t.co/nGqgzn95An http://t.co/hxbGzgGxcW
QUIZ: Which "Love Actually" Character Are You?
↪ http://t.co/sMYI15NRlP
23 EXCELLENT reasons to drink more wine
http://t.co/JmZgwFZVYX http://t.co/wYT3XbxbSn

In [8]:
#remove duplicate headlines
headlines = list(set(headlines))
print len(headlines),'headlines'

#turn the headlines into a list of words
headline_words = [headline.split() for headline in headlines]
headline_words = [word for headline in headline_words for word in headline]
print len(headline_words),'headline words'

#keep only the numbers in the headlines
numbers = [word for word in headline_words if word.isdigit()]
print len(numbers),'numbers used'

#look for whether the headline has any number
any_number = [headline for headline in headlines if len([h for h in headline.split() if h.isdigit()==True])>0] 
print '%02d%% any number' % (len(any_number)/len(headlines)*100)


#then look to see if the first word is a number
numbers_first = [headline for headline in headlines if headline.split()[0].isdigit()==True] 
print '%02d%% number first' % (len(numbers_first)/len(any_number)*100)

#see if it's an odd numbers
odd_numbers = [number for number in numbers if int(number) % 2 ==1 ]
print '%02d%% odd first' % (len(odd_numbers)/len(numbers)*100)


#get the frequency of the number
number_counter = Counter(numbers)
1840 headlines
19021 headline words
886 numbers used
46% any number
82% number first
64% odd first

In [9]:
#Print out the most common numbers
print ' No. Freq'
for number, count in number_counter.most_common()[:23]:
    print '%4d %4d' % (int(number), count)
 No. Freq
  23   54
  21   52
  19   48
  15   47
  17   45
2013   41
  27   36
  18   36
  25   31
  24   29
  33   27
  29   26
  13   26
  14   25
  31   25
  10   24
  20   23
  16   23
  26   22
  22   22
  11   21
  30   20
  35   17

In [10]:
#print out the headlines with the most common number
for headline in headlines:
    if '23' in headline.split():
        print headline
23 photos taken ONE SECOND before utter catastrophe http://t.co/h0qvSi26t9 http://t.co/kyN3I35Xzr
The 23 Most Important Selfies Of 2013 http://t.co/fwHErdPrwz
23 LIES you tell yourself to feel like a grown up http://t.co/e5nr3YCNWQ http://t.co/tBtQ8531HB
23 Easy Tricks To Baby Proof Your House For The Holidays http://t.co/OvzLRKbSfr
The 23 Absolute Worst Parts Of Your Childhood http://t.co/gqp5Kog1Kp
23 DIY Holiday Gifts Kids Can Give To Their Parents http://t.co/b7gZPcP1xi
23 Signs You're A Morning Person http://t.co/9OuKr7LTGq
23 people with better names than yours http://t.co/cs041pPmqu http://t.co/ia7eG2ZWpJ
23 Times Taylor Swift Was Right About Life http://t.co/OizcsCmlGh
23 Moments When You Realize That You Have Failed As A Man http://t.co/M47SXDXH34 http://t.co/3Rr26ycUdh
23 Times Nathan And Haley Made You Believe In True Love http://t.co/GwZG1odBcQ via @mkruvant http://t.co/InbOjwswUk
23 Reasons Neil Gaiman Is The Coolest Author Around http://t.co/EuYTdcwr1B
23 Greatest Thanksgiving Moments From "Friends" http://t.co/sK40EDIlT5
23 Absurdly Lame Things That Happened To Superman, Batman, And Robin http://t.co/KWumjX9Ihd
23 Reasons Why P!nk Is The Role Model Every Girl Should Have http://t.co/CE9GGi9Ee0
23 People With Better Names Than Yours http://t.co/nPxuzPMAHR
23 Tech Problems We All Still Suffer Through http://t.co/Eg7dGO5chq
23 Delicious Vegetarian Hanukkah Recipes http://t.co/o1IBjQQ5Ua
23 Inspirational Signs From The Church Championing Gay Marriage http://t.co/54AQtGejt5
23 Times Nathan And Haley Made You Believe In True Love 
http://t.co/ytDengJjh2 http://t.co/qYSPImghUq
23 Signs You’re A Morning Person
http://t.co/74QuJELqiZ http://t.co/YqVy2WjcVf
23 EXCELLENT reasons to drink more wine
http://t.co/JmZgwFZVYX http://t.co/wYT3XbxbSn
23 things ONLY pale people will understand http://t.co/GOUAKWAcMB http://t.co/WZa3NImGQs
The 23 Most Corrupt Countries In The World http://t.co/kOnT7QGZ4B
23 Lies You Tell Yourself To Feel Like A Grown-Up http://t.co/e5nr3YCNWQ http://t.co/cFXi3ZUytK
23 Tattoos For Coffee Lovers http://t.co/Q3l9PVQ3F3
23 Signs You Might Be Blanche Devereaux From "The Golden Girls" http://t.co/kn100r3jum
23 Times Nathan And Haley Made You Believe In True Love http://t.co/8vHwVJk6qr
The 23 absolute WORST parts of your childhood http://t.co/JvMduxsIgd http://t.co/AhSxufHx9e
23 Signs You’re Obsessed With Christmas http://t.co/tcG3zY5KuY http://t.co/mmMicC3xdI
23 Airport Moments That Will Test Your Will To Live 
http://t.co/tf0nrBCBBo http://t.co/VbQebXdv8Y
The 23 absolute WORST parts of your childhood http://t.co/JvMduxsIgd http://t.co/35B8FasSsl
23 Signs You're Obsessed With Christmas http://t.co/r1xeHk6wjy
23 Geeky Greeting Cards For The Holidays http://t.co/tN4kA4BN6C
23 Reasons You Should Wear White This Winter http://t.co/90Wh3uCXIN
23 Lies You Tell Yourself To Feel Like A Grown-Up http://t.co/2ExR6l7UoI
23 Netflix Suggestions That Make No Sense http://t.co/UnNRExi1vq
23 Airport Moments That Will Test Your Will To Live 
http://t.co/tf0nrBCBBo http://t.co/VDwyUPDfQZ
The 23 Most Midwestern Things To Ever Happen http://t.co/e8BFsR6zcj
23 Snazzy Nail Ideas For Thanksgiving http://t.co/L6UVIY6JsY
23 Photos That Prove Pug Shaming Is The Best Kind Of Dog Shaming http://t.co/SnP6xHAwLk
23 famous people you may have forgotten were on "The O.C."  
http://t.co/ATSy6tWW6J http://t.co/PRKIjSqQzL
23 Ingenious Australian Solutions To Everyday Problems http://t.co/z2WxDOqpOM http://t.co/L9nbNpGbtY
23 Times Amber Riley Was The Fiercest Competitor In "Dancing With The Stars" History http://t.co/VjCXzLVmCh
The 23 MOST important selfies of 2013 
http://t.co/TSTmz9ibWU http://t.co/tPcgcG5YXc
23 EXCELLENT reasons to drink more wine
http://t.co/JmZgwFZVYX http://t.co/Jw1Yg8EwCn
23 Airport Moments That Will Test Your Will To Live http://t.co/DLAVlTkz3H http://t.co/SKm1SrTR9A
23 Times "Parenthood" Made You Cry Happy Tears http://t.co/FBnKDTZuUU
23 Reasons Why Trying To Be Cute On The Internet Is A Terrible Idea http://t.co/s96GqbnvFm
23 Real-Life Struggles Of Being 23 http://t.co/uExAotYa78
23 Defining Traits Of Your Favorite Teacher http://t.co/PpSAMJQXWK
23 photos that PROVE pug shaming is the best kind of dog shaming 
http://t.co/URg1SrvUrT http://t.co/yamTgwvlba
23 Famous People You May Have Forgotten Were On "The O.C." http://t.co/eK5Lz9WLQa

In [11]:
#import tools for graphing
%matplotlib inline
import pandas as pd
In [12]:
#make a histogram for numbers smaller than 40
small_numbers = [int(number) for number in numbers if int(number) <= 40 ]
df = pd.DataFrame(small_numbers, columns =['Buzzfeed Headline Numbers'])
df.hist(bins=40)
Out[12]:
array([[<matplotlib.axes.AxesSubplot object at 0x10818f0d0>]], dtype=object)
In [14]:
#ignore code below. Imports style sheet for this page.

from IPython.core.display import HTML
def css_styling():
    styles = open("custom.css", "r").read()
    return HTML(styles)
css_styling()
Out[14]:
In []: