In [64]:
%matplotlib inline
import json
import pandas as pd
import matplotlib.pyplot as plt
import re
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
from pandas.tseries.offsets import DateOffset
import vincent as v
tweets_data_path = 'trump_tweets.json'
tweets_data = []
tweets_file = open(tweets_data_path, "r")
for line in tweets_file:
try:
tweet = json.loads(line)
tweets_data.append(tweet)
except:
continue
print str(len(tweets_data)) + " tweets loaded."
12676 tweets loaded.
In [65]:
tweets = pd.DataFrame()
tweets['text'] = map(lambda tweet: tweet['text'].encode('utf-8'), tweets_data)
tweets['lang'] = map(lambda tweet: tweet['lang'], tweets_data)
tweets['country'] = map(lambda tweet: tweet['place']['country'] if tweet['place'] != None else None, tweets_data)
tweets['created_at'] = pd.to_datetime(map(lambda tweet: tweet['created_at'], tweets_data))
tweets['geo'] = map(lambda tweet: tweet['geo'], tweets_data)
tweets['source'] = map(lambda tweet: tweet['source'], tweets_data)
tweets.set_index('created_at', drop=False, inplace=True)
tweets.index = tweets.index.tz_localize('GMT').tz_convert('EST')
tweets.index = tweets.index - DateOffset(hours = 12)
tweets1m = tweets['created_at'].resample('1t', how='count')
In [66]:
#print tweets
In [67]:
v.core.initialize_notebook()
area = v.Area(tweets1m)
area.colors(brew='Spectral')
area.display()
In [68]:
text = " ".join(tweets['text'].values.astype(str))
text_without_garbage = " ".join([word for word in text.split()
if 'http' not in word
and not word.startswith('@')
and word != 'RT'])
wc = WordCloud(background_color='white',font_path="/Library/Fonts/Verdana.ttf",
stopwords=STOPWORDS, width=1920, height=1080)
wc.generate(text_without_garbage)
plt.imshow(wc)
plt.axis("off")
plt.show()
In [69]:
tweets[tweets['lang'] == 'es']
Out[69]:
text
lang
country
created_at
geo
source
created_at
2016-02-23 03:38:47-05:00
Marco Rubio, Hillary Clinton y Donald Trump so...
es
None
2016-02-23 20:38:47
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 03:38:59-05:00
RT @EnriquePocacosa: Como Donald Trump,Peñalos...
es
None
2016-02-23 20:38:59
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 03:39:16-05:00
Noticias El vídeo del hombre travestido de Sai...
es
None
2016-02-23 20:39:16
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:21-05:00
El vídeo del hombre travestido de Sailor Moon ...
es
None
2016-02-23 20:39:21
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:21-05:00
El vídeo del hombre travestido de Sailor Moon ...
es
None
2016-02-23 20:39:21
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:21-05:00
El vídeo del hombre travestido de Sailor Moon ...
es
None
2016-02-23 20:39:21
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:21-05:00
El vídeo del hombre travestido de Sailor Moon ...
es
None
2016-02-23 20:39:21
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:21-05:00
El vídeo del hombre travestido de Sailor Moon ...
es
None
2016-02-23 20:39:21
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 03:39:50-05:00
El gran pedo con Donald Trump es siquiera imag...
es
None
2016-02-23 20:39:50
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 03:40:21-05:00
Donald Trump aspira a ganar en Nevada\nhttps:/...
es
None
2016-02-23 20:40:21
None
<a href="http://www.hootsuite.com" rel="nofoll...
2016-02-23 03:40:34-05:00
RT @TWD_ES: #TWDFanEvent. "Escogería a Donald ...
es
None
2016-02-23 20:40:34
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:41:54-05:00
Muy grande Abraham 😂 https://t.co/kqKSoaCI4P
es
None
2016-02-23 20:41:54
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:42:34-05:00
RT @qtf: Basta de estupideces:\n¡Quien quiera ...
es
None
2016-02-23 20:42:34
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:42:35-05:00
https://t.co/GwnAYzMxCq Retweeted RT BigMacguf...
es
None
2016-02-23 20:42:35
None
<a href="http://ifttt.com" rel="nofollow">IFTT...
2016-02-23 03:47:03-05:00
RT @BigMacguffin: Donald Trump, compañero idea...
es
None
2016-02-23 20:47:03
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 03:47:08-05:00
¿Qué opina "El Chapo" de Donald Trump?, respon...
es
None
2016-02-23 20:47:08
None
<a href="https://about.twitter.com/products/tw...
2016-02-23 03:47:38-05:00
RT @BigMacguffin: Donald Trump, compañero idea...
es
None
2016-02-23 20:47:38
None
<a href="https://mobile.twitter.com" rel="nofo...
2016-02-23 03:48:25-05:00
RT @FansWWEUniverse: Shane McMahon volverá a u...
es
None
2016-02-23 20:48:25
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:48:42-05:00
RT @marianaatencio: ¿Qué opina "El Chapo" de D...
es
None
2016-02-23 20:48:42
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 03:49:02-05:00
No existen los atajos para los lugares que val...
es
None
2016-02-23 20:49:02
None
<a href="http://www.tweetcaster.com" rel="nofo...
2016-02-23 03:49:11-05:00
Hay que destruir en todo el mundo a gobiernos ...
es
None
2016-02-23 20:49:11
None
<a href="https://about.twitter.com/products/tw...
2016-02-23 03:49:13-05:00
Si de todos modos hay que pensar, más vale pen...
es
None
2016-02-23 20:49:13
None
<a href="http://www.tweetcaster.com" rel="nofo...
2016-02-23 03:49:15-05:00
RT @JuanRaCorrea: "@TheCWW: Adolf Hitler vs. D...
es
None
2016-02-23 20:49:15
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 03:49:20-05:00
'Me dan ganas de soltarle un puñetazo en la ca...
es
None
2016-02-23 20:49:20
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 03:49:53-05:00
Donald Trump se perfila como favorito por los ...
es
None
2016-02-23 20:49:53
None
<a href="http://ifttt.com" rel="nofollow">IFTT...
2016-02-23 03:50:24-05:00
RT @Cerrake: Y Donald Trump llegó a Game of Th...
es
None
2016-02-23 20:50:24
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:50:38-05:00
RT @TWD_ES: #TWDFanEvent. "Escogería a Donald ...
es
None
2016-02-23 20:50:38
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:50:39-05:00
RT @Fresavzla: ¿Por qué la hija de Donald Trum...
es
None
2016-02-23 20:50:39
None
<a href="http://twitter.com/download/android" ...
2016-02-23 03:50:46-05:00
RT @TWD_ES: #TWDFanEvent. "Escogería a Donald ...
es
None
2016-02-23 20:50:46
None
<a href="http://twitter.com/#!/download/ipad" ...
2016-02-23 03:51:40-05:00
RT @TWD_ES: #TWDFanEvent. "Escogería a Donald ...
es
None
2016-02-23 20:51:40
None
<a href="https://mobile.twitter.com" rel="nofo...
...
...
...
...
...
...
...
2016-02-23 04:39:06-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:39:06
None
<a href="http://ifttt.com" rel="nofollow">IFTT...
2016-02-23 04:39:09-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:39:09
None
<a href="http://dlvr.it" rel="nofollow">dlvr.i...
2016-02-23 04:39:11-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:39:11
None
<a href="http://dlvr.it" rel="nofollow">dlvr.i...
2016-02-23 04:39:11-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:39:11
None
<a href="http://dlvr.it" rel="nofollow">dlvr.i...
2016-02-23 04:39:56-05:00
Cualquier parecido con @AlvaroUribeVel es coin...
es
None
2016-02-23 21:39:56
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 04:39:58-05:00
RT @OctavioLopezSie: Cow boy gringo vs "Ganade...
es
None
2016-02-23 21:39:58
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 04:40:03-05:00
"Soy latino y votaré por Donald Trump en Nevad...
es
None
2016-02-23 21:40:03
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 04:41:10-05:00
Con ello me da para un ejército para luchar co...
es
None
2016-02-23 21:41:10
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 04:41:23-05:00
RT @foxtves: #TWDFanEvent. "Escogería a Donald...
es
None
2016-02-23 21:41:23
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 04:41:29-05:00
EM: La guerra de Univision a Donald Trump http...
es
None
2016-02-23 21:41:29
None
<a href="http://twitterfeed.com" rel="nofollow...
2016-02-23 04:41:44-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:41:44
None
<a href="http://twitter.com" rel="nofollow">Tw...
2016-02-23 04:41:45-05:00
RT @libertaddigital: Jordi Évole y Donald Trum...
es
None
2016-02-23 21:41:45
None
<a href="http://twitter.com/#!/download/ipad" ...
2016-02-23 04:42:40-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:42:40
None
<a href="http://ifttt.com" rel="nofollow">IFTT...
2016-02-23 04:42:51-05:00
¡Existen! \n\n"Soy latino y votaré por Donald ...
es
None
2016-02-23 21:42:51
None
<a href="https://about.twitter.com/products/tw...
2016-02-23 04:43:09-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:43:09
None
<a href="http://dlvr.it" rel="nofollow">dlvr.i...
2016-02-23 04:44:20-05:00
RT @ElviRivasR: Donald Trump sobre Michael Blo...
es
None
2016-02-23 21:44:20
None
<a href="http://twitter.com/#!/download/ipad" ...
2016-02-23 04:44:26-05:00
@YsminBA que tiene de malo donald trump? Cada...
es
None
2016-02-23 21:44:26
None
<a href="https://mobile.twitter.com" rel="nofo...
2016-02-23 04:44:26-05:00
Buuuuurrro https://t.co/eUfyb3vlFe
es
None
2016-02-23 21:44:26
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 04:44:36-05:00
Según mi tía la de Nueva York allí nadie quier...
es
None
2016-02-23 21:44:36
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 04:44:36-05:00
Primarias en EE.UU.: el gran negocio del imita...
es
None
2016-02-23 21:44:36
None
<a href="http://ifttt.com" rel="nofollow">IFTT...
2016-02-23 04:44:48-05:00
Miriam Witcher :\n"Amo a Donald Trump, amo al ...
es
None
2016-02-23 21:44:48
None
<a href="http://twitter.com/download/android" ...
2016-02-23 04:45:26-05:00
Revelan la posible razón del odio que siente D...
es
None
2016-02-23 21:45:26
None
<a href="http://www.hootsuite.com" rel="nofoll...
2016-02-23 04:45:57-05:00
Aprende todo lo que puedas sobre lo que estás ...
es
None
2016-02-23 21:45:57
None
<a href="http://www.tweetcaster.com" rel="nofo...
2016-02-23 04:46:20-05:00
RT @DebeSaberQue: Los negocios son mi forma de...
es
None
2016-02-23 21:46:20
None
<a href="http://www.michelpesquera.com" rel="n...
2016-02-23 04:46:44-05:00
La guerra de Univision a Donald Trump: Leer ht...
es
None
2016-02-23 21:46:44
None
<a href="http://www.google.com/" rel="nofollow...
2016-02-23 04:47:06-05:00
RT @GlobovisionWeb: Primarias en EE.UU.: el gr...
es
None
2016-02-23 21:47:06
None
<a href="http://bluebaron.net/" rel="nofollow"...
2016-02-23 04:47:14-05:00
https://t.co/uoyl3CkjDE mendigo rasista el din...
es
United States
2016-02-23 21:47:14
{u'type': u'Point', u'coordinates': [35.372405...
<a href="http://twitter.com/download/android" ...
2016-02-23 04:47:55-05:00
RT @marta_ter: Buenísimo! Johnny Depp se quita...
es
None
2016-02-23 21:47:55
None
<a href="http://twitter.com/download/iphone" r...
2016-02-23 04:48:01-05:00
#UNAMosPET vs #DONALDTRUMP\nHEY Donald J. Trum...
es
None
2016-02-23 21:48:01
None
<a href="http://www.facebook.com/twitter" rel=...
2016-02-23 04:48:46-05:00
RT @bbcmundo: El gran negocio del imitador de ...
es
None
2016-02-23 21:48:46
None
<a href="http://twitter.com/download/android" ...
281 rows × 6 columns
In [70]:
print "Average tweets per minute: " + str(tweets1m.mean())[:5] + ", max was " + str(tweets1m.max())
Average tweets per minute: 178.5, max was 266
In [71]:
print tweets.source.value_counts()
<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a> 3847
<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a> 3204
<a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a> 2160
<a href="http://twitter.com/#!/download/ipad" rel="nofollow">Twitter for iPad</a> 574
<a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a> 427
<a href="https://about.twitter.com/products/tweetdeck" rel="nofollow">TweetDeck</a> 362
<a href="http://ifttt.com" rel="nofollow">IFTTT</a> 355
<a href="http://www.facebook.com/twitter" rel="nofollow">Facebook</a> 153
<a href="http://dlvr.it" rel="nofollow">dlvr.it</a> 130
<a href="http://mobile.twitter.com" rel="nofollow">Mobile Web</a> 102
<a href="http://linkis.com" rel="nofollow">Linkis.com</a> 102
<a href="https://mobile.twitter.com" rel="nofollow">Mobile Web (M5)</a> 99
<a href="http://www.google.com/" rel="nofollow">Google</a> 79
<a href="http://www.hootsuite.com" rel="nofollow">Hootsuite</a> 68
<a href="http://tapbots.com/tweetbot" rel="nofollow">Tweetbot for iΟS</a> 59
<a href="https://roundteam.co" rel="nofollow">RoundTeam</a> 56
<a href="http://www.twitter.com" rel="nofollow">Twitter for Windows Phone</a> 52
<a href="http://www.tweetcaster.com" rel="nofollow">TweetCaster for Android</a> 50
<a href="http://publicize.wp.com/" rel="nofollow">WordPress.com</a> 43
<a href="http://bluebaron.net/" rel="nofollow">jCarApp</a> 42
<a href="https://mobile.twitter.com" rel="nofollow">Mobile Web (M2)</a> 34
<a href="http://www.voteus.info" rel="nofollow">iTweet for Reform</a> 27
<a href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow">Twitter for Mac</a> 27
<a href="https://twitter.com/download/android" rel="nofollow">Twitter for Android Tablets</a> 26
<a href="http://www.tweetedtimes.com" rel="nofollow">The Tweeted Times</a> 24
<a href="http://www.socialflow.com" rel="nofollow">SocialFlow</a> 24
<a href="http://bufferapp.com" rel="nofollow">Buffer</a> 22
<a href="http://www.twitter.com" rel="nofollow">Twitter for Windows</a> 20
<a href="http://www.twitter.com" rel="nofollow">Twitter for BlackBerry</a> 19
<a href="http://www.echofon.com/" rel="nofollow">Echofon</a> 19
...
<a href="http://testn.macavalon.com" rel="nofollow">celeb universal app</a> 1
<a href="http://draldevelopment.uk" rel="nofollow">Golf news on twitter</a> 1
<a href="https://twitter.com/cobaltkobra" rel="nofollow">Twitter Breadcrumb Client</a> 1
<a href="http://www.noplaceto.be" rel="nofollow">Auth App 928344</a> 1
<a href="http://www.rezar.com" rel="nofollow">PrayApp</a> 1
<a href="http://ahmetada.com" rel="nofollow">coreenproverbs_app</a> 1
<a href="http://ahmetada.com" rel="nofollow">psychologymarcy_app</a> 1
<a href="http://127.0.0.1" rel="nofollow">2b454cfc5a3715a060bc7b318b095735</a> 1
<a href="http://clapway.com" rel="nofollow">Clapway-post</a> 1
<a href="https://twitter.com/download/android" rel="nofollow">Twitter for Android</a> 1
<a href="http://rightrelevance.com/?q=tab_type%3D1%26value%3Dwashington%2520dc%26searchType%3Dexperts%26start%3D0%26rows%3D10%26location%" rel="nofollow">Washington DC RR</a> 1
<a href="http://www.guldar.com/" rel="nofollow">Guldar Australia</a> 1
<a href="http://my7oprahnextstory.com" rel="nofollow">my7oprahnextstory</a> 1
<a href="http://pinterest.com" rel="nofollow">Pinterest</a> 1
<a href="http://www.google.com" rel="nofollow">TwitterJava22</a> 1
<a href="https://twitter.com/menewsytweets" rel="nofollow">menewsytweets app</a> 1
<a href="http://politdecal.com" rel="nofollow">politdecal ver 3</a> 1
<a href="http://vine.co" rel="nofollow">Vine - Make a Scene</a> 1
<a href="http://Hireahire.com" rel="nofollow">HireaHire</a> 1
<a href="http://www.newspaperpost.com/" rel="nofollow">Newspaper Post </a> 1
<a href="http://dragplus.com" rel="nofollow">DragPlus</a> 1
<a href="https://www.yabberz.com" rel="nofollow">yabberz_melissa</a> 1
<a href="http://185.87.49.34" rel="nofollow">Trifourex</a> 1
<a href="http://www.newzsocial.com" rel="nofollow">NewzSocial</a> 1
<a href="http://www.dreamdevelopment.be" rel="nofollow">MeTweets for Windows Phone</a> 1
<a href="http://www.1001portails.com" rel="nofollow">1001ptsau_4</a> 1
<a href="https://www.socialjukebox.com" rel="nofollow">The Social Jukebox</a> 1
<a href="http://radio3.io/" rel="nofollow">radio3.io</a> 1
<a href="http://www.recitenews.com" rel="nofollow">Recite News</a> 1
<a href="https://play.google.com/store/apps/details?id=com.dwdesign.tweetings" rel="nofollow">Tweetings for Android</a> 1
Name: source, dtype: int64
In [83]:
import nltk
from nltk.corpus import stopwords
from nltk import FreqDist
stop = stopwords.words('english')
text = tweets['text']
stop.append(['rt','via','-','_'])
freqdist = nltk.FreqDist([t for t in text_without_garbage.split() if t.lower() not in stop])
freqdist.plot(25)
/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:10: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
In [91]:
retweets = tweets[tweets['text'].str.contains("RT")]
retweets.text.value_counts()
Out[91]:
RT @TeamTrumpAZ: Live Stream: Donald Trump Holds Rally in Sparks, NV (2-23-16) https://t.co/bl2U0CQik9 #NEVADACAUCUS #NEVADA#Trump https:… 300
RT @gregorykorte: "Nobody reads the Bible more than me." -- Donald J. Trump, just now. 291
RT @TheCWW: Adolf Hitler vs. Donald Trump https://t.co/iWWFkeYaGz 218
RT @TooHighBros: The "I'm voting for Donald Trump starter pack" https://t.co/CMRALTy16j 148
RT @ClassicPict: Donald Trump v Adolf Hitler https://t.co/TJBmi50MhX 132
RT @TheDailyShow: Ugandans answer the question: Donald Trump or their corrupt dictator Yoweri Museveni?\nhttps://t.co/txwFnozppj 125
RT @SteveDeaceShow: Lord, have mercy. I know this megalomaniac is what we deserve, but give us grace, Lord. Give us grace. https://t.co/1R… 110
RT @nytimes: Donald Trump is no power broker in NYC, despite all the signs https://t.co/YthZvKkHSB https://t.co/wudJ0mFKWx 108
RT @dog_rates: I know it's tempting, but please stop sending in pics of Donald Trump. Thank you ...9/10 https://t.co/y35Y1TJERY 102
RT @WorldOfStu: Literally lying about the bible. RT @gregorykorte: “Nobody reads the Bible more than me.” -- Donald J. Trump, just now. 55
RT @xcaseadillax: Bernie Sanders is so done with Donald Trump's shit and I love it. https://t.co/n5TEQWBZFF 54
RT @LindaSuhler: Donald Trump at Las Vegas rally just now:\n"Political Correctness is KILLING this country."\nCrowd went wild.\n#CaucusForTrum… 53
RT @JonahNRO: Nobody. https://t.co/O2yRnA53gX 51
RT @BernieSanders: If you want a candidate who is going to defeat Donald Trump, you’re looking at him. \nhttps://t.co/Zo0GTdE0MZ 51
RT @NumbersMuncher: Want to talk about being robotic- Trump answers every subject with "Nobody does XYZ more than me, let me tell you." htt… 50
RT @realDonaldTrump: Join us in Sparks, Nevada today! \n#NevadaCaucus #VoteTrumpNV \nhttps://t.co/5DyhPftng9 50
RT @joecarter: Sometimes I think The Donald is just trying to see how big a lie he can tell before his cult will call him out. https://t.co… 46
RT @WayneDupreeShow: LIVE Stream: Donald Trump Rally in Sparks, NV 3 PM EST — Watch/Chat with us! https://t.co/nrDQpnRLPw #TeamTrump #Trum… 45
RT @M_Ullah: This is how Donald Trump writes his speeches https://t.co/wDmnN9VC16 42
RT @bydanielvictor: We’re going to build a big, beautiful paywall https://t.co/ZNSpdhMZOs 41
RT @samueld_james: I give up. https://t.co/cG18mjnQLs 41
RT @noonanjo: I'm a former nuclear missile officer. The thought of this guy with the authenticators is unnerving. https://t.co/DwPFkrdhuy 36
RT @katherinemiller: So Elizabeth — when she was young, very charming, very, very charming. Could't have a baby. Sad. Really sad. https://… 35
RT @BBCNewsUS: Here is what Mexicans think of that "big beautiful wall" Donald Trump says he'll build https://t.co/cCBlhf2aiR https://t.co/… 34
RT @RichLowry: Someone tell the pope https://t.co/8Xa2ERWWsb 34
RT @DylanByers: Donald Trump just said The New York Times is “owned by Mexico.” 34
RT @JayCaruso: If ACU is so concerned about conservatives at CPAC, THEY WOULD NOT INVITE DONALD TRUMP. 33
RT @LordSnow: Winter is Trumping: Donald Trump meets Game of Thrones by @rabbitandcoffee #Insiders https://t.co/fLfbni0ebs 33
RT @neverknownfacts: Donald Trump hasn't spent a dime on TV ads, but has been the subject of at least 2,159 CNN reports since becoming a pr… 32
RT @marchio_j: @JaredWyand Rep have an obligation to pick the strongest candidate, and that is Donald Trump. America needs & wants Trump. 31
...
RT @AesopRockWins: Uh... Guys... Is uh... Donald Trump gonna like... Be our president? 1
RT @SmartInsults: Very sad to hear about Donald Trump. Nothing happened to him i'm just sad to hear about him 1
RT @MyVWSucks: Maybe it's the water in New York. Rudy Giuliani still can't utter a sentence without saying 9/11 & Donald Trump screams Wall… 1
RT @MetroUK: Donald Trump says he wants to ‘punch protester in the face’ https://t.co/jhaBBDRLYQ 1
RT @digi__mike: Make America's socks great again hahahaha - Ici https://t.co/6VMuR013LP https://t.co/EWPhDr1jxz 1
RT @CapitalOfficial: Donald Trump is on about building a wall... In this IMMENSE Game of Thrones mash-up that you'd be a fool to miss! 😂 ht… 1
RT @wpjenna: At town hall with Hannity, Donald Trump says this tweet "was done for fun." He notes that he used a question mark. https://t.c… 1
RT @thesouthern: Democrat Hillary Clinton and Republican Donald Trump lead their respective fields in the presidential race in... https://t… 1
RT @TIME: Watch Donald Trump dodge a bald eagle https://t.co/Ny1geLWxnU https://t.co/Be8wMhVqCI 1
RT @jesseberney: Donald Trump has an additional set of eyes on his chest constantly reading bible verses printed inside his shirt. https://… 1
RT @Johnatsrs1949: Live Stream: Donald Trump Holds Rally in Sparks, NV (2-23-16)12:00 PM PST https://t.co/b67qRYm4xc https://t.co/wLsq6BBMJ7 1
RT @taehyungierise: ALBA JUST SAID ENGLISH LOVE AFFAIR WAS AS UGLY AS DONT STOP HOW CAN YOU ITS LIKE COMPARING BARS OF GOLD TO DONALD TRUMP 1
@ElPachaOficial EL Canto Contra 'Trump Donald Trump You're Fired" Video Nuevo #DTYF #RT https://t.co/twVCo0OwJB 1
RT @TodayMiami: Could Donald Trump Pick Rick Scott as His Running Mate? #politics 1
RT @NewNowNext: A drag queen Julia Sugarbaker goes AWF on Donald Trump in classic "Designing Women" style: https://t.co/VxKqZCyjxJ https://… 1
RT @MWrexLibs16: I can't wait for President Donald Trump to kick that Muslim loving hack out of the White House! He will #MakeAmericaGreatA… 1
NIGGA! RT @VanteEllis: What if Donald Trump really wins? It isn’t funny, yet it really is…. Lmaooo 1
RT @ChateauEmissary: And GOD BLESS HIM for that. (the Christian God)\nhttps://t.co/UpfxXoIwKb 1
RT @ggxbyy: "white privilege isn't real" "Donald trump has good points" "saying the n word if ur not black isn't racist" y'all I'm about to… 1
RT @CottonyMouth: Un burro y una zorra en la presidencia, me recuerda a México. Solo que éste burro es más racista y pendejo https://t.co… 1
RT BBCWorld "RT BBCNewsUS: Here is what Mexicans think of that "big beautiful wall" Donald Trump says he'll build... https://t.co/SK1gDpCRcm 1
RT @joehubz: Remember kids, Donald Trump wants to bang his daughter. #Fact #GOP #Presidential? #Election2016 #Republicanprimary @realDonal… 1
RT @clmazin: I'm not saying anything that hard to figure out. Ted Cruz is a clumsy parlor trick. He's the Benny Hinn of politics. https://t… 1
THE MUCH TALKED ABOUT NATIONAL REVIEW ARTICLE DENOUNCING TRUMP'S CONSERVATIVE CREDENTIALS... https://t.co/aom7k4ykVR 1
RT @killer_reviews1: LETS ALL CRAP ON DONALD TRUMP ! https://t.co/Kt6QBUDVz1 https://t.co/lDAk7EdkBU 1
RT @RLibertyCaucus: Donald J. Trump apparently supports #AuditTheFed. #RLC https://t.co/aXU1q7su5w 1
RT @kindcutesteve: Nonpresidential Trump on #NV Protester: 'I'd Like to Punch Him' https://t.co/BesWVmNIrB #p2 #AINF #TNTVote https://t.co/… 1
RT @ajpaniagua: Alguien ha metido a Donald Trump en @JuegoDeTronosTM y el resultado es genial... 😂 https://t.co/0rnjT4nLrb 1
RT @oldstocknews: Cant wait until Trump spanks Canada's liberal lying Prime Minister and jams the XL PIPELINE up his arse https://t.co/Brri… 1
RT @bobo_willie: Sen. Lindsey Graham, R-S.C., said that it would be better for a Democrat to win the White House than Donald Trump. https:/… 1
Name: text, dtype: int64
In [115]:
donald_count = tweets[tweets['text'].str.lower().str.contains("trump")]['text'].count()
trump_count = tweets[tweets['text'].str.lower().str.contains("donald")]['text'].count()
print "Tweets surveyed: " + str(tweets['text'].count())
print "Tweets with 'Donald': " + str(donald_count)
print "Tweets with 'Trump': " + str(trump_count)
print "'Donald' to 'Trump' Ratio: " + str(donald_count/float(trump_count))[:4] + ":1"
Tweets surveyed: 12676
Tweets with 'Donald': 10364
Tweets with 'Trump': 9571
'Donald' to 'Trump' Ratio: 1.08:1
In [ ]:
Content source: bcongdon/Data-Science-Projects
Similar notebooks: