Muslim ban analysis

Preliminary analysis of tweets set from January 28


In [1]:
%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

tweets = pd.read_json("https://s3.amazonaws.com/far-right/twitter/mb_protests.json")
tweets


Out[1]:
created friends_count hashtags id_str text user_created user_description user_followers user_location user_name
0 2017-01-29 01:50:47.000000 1588 ["MuslimBan", "HateisHate"] 825521540498329600 If you stand for a #MuslimBan you are no bette... 2010-05-18 18:58:24.000000 🎙💼Attorney, Advocate #justicefighter #notonest... 3180 Atlanta, Ga.\n AttorneyGriggs
1 2017-01-29 01:50:47.000000 1016 ["MuslimBan"] 825521543006416896 Great to see! RT @tarynoneill: My entire feed ... 2008-07-10 23:00:32.000000 Midwest native and Bay Area resident. Opinions... 852 Oakland, CA RogueHacker
10 2017-01-29 01:50:49.000000 1251 [] 825521550526869504 Holy shit that's alot of people https://t.co/n... 2014-09-26 07:12:00.000000 Shake and Bake👻: og-fatboy📸: 661xzombie 446 Hollywoo VivaLABonzo
100 2017-01-29 01:51:06.000000 1114 ["MuslimBan"] 825521618948616192 La verità è che non conosciamo mezze misure, c... 2011-10-19 12:40:12.000000 Beati coloro che sanno ridere di se stessi per... 1131 Taormina concettaconsoli
1000 2017-01-29 01:53:47.000000 119 ["JFKTerminal4", "MuslimBan", "occupyairports"... 825522295850536960 #JFKTerminal4 #MuslimBan #occupyairports #Faci... 2011-03-23 15:13:56.000000 Where politics meets sports meets poetics, and... 86 New York Metropolitan Area wolftoothe
10000 2017-01-29 02:24:48.000000 1889 ["MuslimBan"] 825530103367036928 The brainwashing is strong in this one.#Muslim... 2009-07-22 22:34:55.000000 Forget world peace, visualize using your turn ... 1437 Californiastine XoduzMidnight
100000 2017-01-29 04:45:02.000000 9249 ["tcot"] 825565392730980352 Trump Didn’t Fire FBI Director James Comey Aft... 2008-06-27 17:50:53.000000 AIM is America's original media watchdog, prom... 22793 Washington, DC AccuracyInMedia
100001 2017-01-29 04:45:03.000000 280 ["FAKENEWS"] 825565396606603264 #FAKENEWS exposed https://t.co/IJRcvO1N43 2016-05-21 23:45:09.000000 NY METS FAN! Guitar Player. Comic Book Collect... 187 New York, USA EDDIEMETS
100002 2017-01-29 04:45:03.000000 2173 ["MAGA"] 825565397747376128 All he has done is for America First!!! #MAGA ... 2012-11-20 20:15:00.000000 Independent observer 998 USA MediaObservers
100003 2017-01-29 04:45:04.000000 1320 [] 825565401278976000 @CNN https://t.co/TLMDvwtmDT 2016-12-07 17:28:05.000000 Grew up under communism and legally immigrated... 690 Dallas, TX votedforthe45th
100004 2017-01-29 04:45:04.000000 108 ["MAGA"] 825565402193293312 @AP4LP This is where Trumpsters have to set do... 2016-02-19 14:50:03.000000 #Latino #Liberty #Conservative #Republican Jus... 84 Liberal LA, California LALopez1999
100005 2017-01-29 04:45:05.000000 22 ["CNN", "Aclu"] 825565403267035136 @realDonaldTrump whew....thank you to the ACLU... 2013-01-28 19:02:17.000000 Peaceful and doing my best to keep it in persp... 11 None jwpeace9
100006 2017-01-29 04:45:05.000000 345 ["ACLU"] 825565407088046080 @bpolitics @technology while Zuckerbook is con... 2012-01-02 04:09:00.000000 He is passionate about pizzas, Italy, Northern... 127 Fairfield, CA npgnapoli
100007 2017-01-29 04:45:06.000000 946 [] 825565408459575296 Study either immigration law or constitutional... 2009-03-29 20:17:10.000000 Seeker of Justice, for a Price. 616 The OC, California OCHittman
100008 2017-01-29 04:45:08.000000 89508 ["berlin", "maga", "isis", "pjnet"] 825565416349114368 Islam: No compulsion (Except for kids) #berl... 2012-09-16 05:20:05.000000 Author and independent researcher focused on I... 91759 Australia PeterTownsend7
100009 2017-01-29 04:45:09.000000 233 ["AmericaFirst"] 825565419939385344 Exactly Tina! #AmericaFirst for a change :) ht... 2009-05-21 01:29:21.000000 Here to raise awareness. ... 554 VEGAS V0NNiEE
10001 2017-01-29 02:24:49.000000 105 ["MuslimBan"] 825530103828451328 #MuslimBan is great, I shall drink my fill of ... 2016-08-17 14:09:00.000000 Liberals have fallen into a deep abyss of dest... 198 United States silence_above
100010 2017-01-29 04:45:10.000000 181 [] 825565424339341312 Goat https://t.co/hGfXDUpaFx 2015-11-03 16:22:22.000000 🇵🇸| الحمد لله //Sc-AltamimiLaith 281 #FreePalestine 56altamimi
100011 2017-01-29 04:45:10.000000 345 ["aclu", "muslimban", "MuslimBanprotest"] 825565424288886784 Thank you #aclu #muslimban #MuslimBanprotest h... 2014-10-25 03:09:45.000000 Christian, feminist, advocate for justice, m... 69 Orange County Caldwell75Lora
100012 2017-01-29 04:45:12.000000 3593 ["America", "MAGA", "PresidentTrump", "God"] 825565433147379712 Remember.. Rome wasn't build in a day and #Ame... 2011-09-28 08:57:49.000000 #OEFVeteran #WWPAlumni #RetiredVeteran #F15CC ... 1583 United States RareGuy4Cures
100013 2017-01-29 04:45:13.000000 5619 ["Trump", "Nazis", "hero", "MAGA"] 825565438738386944 Be it known that #Trump is promoting hate thro... 2014-01-28 14:10:15.000000 Advocate & Activist 4 the disenfranchised *Hum... 5192 New York, NY uptnhrlmb
100014 2017-01-29 04:45:14.000000 278 ["ACLU", "NY", "defendWL", "ctl"] 825565441552744448 @wikileaks @ACLU U know what 's disturbing. I ... 2016-03-02 08:44:16.000000 Integrity = #BernieSanders #NoDAPL #FightCorr... 68 None thebling_vote
100015 2017-01-29 04:45:14.000000 678 ["ACLU"] 825565442546733056 "If you are neutral in times of injustice, you... 2009-04-19 02:51:42.000000 None 321 None iamanotheru
100016 2017-01-29 04:45:14.000000 1295 ["MuslimBan"] 825565443511418880 Just FYI before you all lose your hair and cla... 2011-06-24 03:50:24.000000 If you live a great life instead of being mise... 328 America JarredBrockwell
100017 2017-01-29 04:45:14.000000 69 ["muslimban", "Aclu"] 825565444312547328 Decency/rule of law > president bannon ... 2010-04-25 01:36:31.000000 I like to overuse hashtags and enjoy food and ... 54 Madison/New York ThatsSoRaven1
100018 2017-01-29 04:45:14.000000 452 ["MAGA"] 825565444425785344 @MONAKatOILS ENOUGH! GET all those crooked lib... 2016-10-01 12:57:16.000000 🇺🇸OURS PRESIDENT TRUMP🙏🏻🇺🇸Dream highly❤️️ #MAG... 878 United States jlizza1
100019 2017-01-29 04:45:15.000000 701 [] 825565445109465088 Great, let's add to the list anypne who voted ... 2013-07-29 18:00:14.000000 GOD (Christ 1st), Family (my wife & little gir... 874 None CJ4FLORIDA
10002 2017-01-29 02:24:48.000000 4347 ["AMERICANvalues", "NoBanNoWall", "NoMuslimReg... 825530103421480960 Powerful image in support of #AMERICANvalues #... 2009-09-30 15:22:51.000000 Robert V. Taylor - Author, Speaker and Activat... 4507 Seattle & rural Eastern WA robertvtaylor
100020 2017-01-29 04:45:15.000000 644 ["POTUS", "USA", "MAGA"] 825565447173058560 @mcuban @PressSec oh @mcuban you don't need to... 2015-02-20 02:54:31.000000 Wife and Mom that loves life! I love all peop... 136 None GailFortunato
100021 2017-01-29 04:45:15.000000 2062 ["TRUMP45", "MAGA"] 825565448427053056 .@DanScavino God Thank you for your mercy! We ... 2015-09-10 01:00:34.000000 Donald J. Trump the 45th President of the Unit... 3790 None MyriamWinner
... ... ... ... ... ... ... ... ... ... ...
99972 2017-01-29 04:44:44.000000 86 ["RESIST", "ACLU"] 825565315002146816 @CasMudde @ACLU #RESIST #ACLU https://t.co/aeI... 2007-05-30 07:50:35.000000 I invented the piano-key necktie! What have yo... 29 Chicagoland kyleg
99973 2017-01-29 04:44:44.000000 205 [] 825565317694947328 Is this a joke? https://t.co/aLpiutnJTa 2016-12-06 04:33:00.000000 Journalist | CLE🛫NYC | @cunysocialj 2017 cohor... 45 New York, NY sanfordreports
99974 2017-01-29 04:44:44.000000 47 ["MAGA", "Trump"] 825565317908819968 This country gets better by the day #MAGA #Trump 2016-05-09 21:24:42.000000 None 57 delco hunterbeck23
99975 2017-01-29 04:44:45.000000 132 ["usa", "Americafirst", "Protestmarches"] 825565321973071872 #usa #Americafirst #Protestmarches People sho... 2016-08-19 19:31:23.000000 None 205 None szymonuak
99976 2017-01-29 04:44:45.000000 1015 [] 825565323130761216 I guess you do.The man ain't stood on his own ... 2013-05-29 03:49:42.000000 I say what I mean2open dialogue. Let be able t... 392 united states cannaloop
99977 2017-01-29 04:44:47.000000 4694 ["internettoughguy", "MAGA"] 825565329204064256 @muckrakery pahahaha.... That's funny. #intern... 2009-02-18 15:50:34.000000 I run @ScoutFantasy and the FFWorld Championsh... 9835 Indianapolis, IN ScottFantasy
99978 2017-01-29 04:44:48.000000 696 ["HolocaustPresidentTrump", "letthefamiliesout... 825565332018438144 #HolocaustPresidentTrump #letthefamiliesout #l... 2012-05-10 15:04:39.000000 Never trump 220 Little Canada MN Chrismf6
99979 2017-01-29 04:44:48.000000 48 ["AmericaFirst"] 825565335554240512 #AmericaFirst 2008-10-22 19:00:09.000000 Trending World News by Nigeria's #socialmedia ... 70514 Nigeria: Africa: Global HNNAfrica
9998 2017-01-29 02:24:48.000000 411 ["MuslimBan", "TRUMPdisaster", "racism", "Refu... 825530102565834752 Can someone please wake us up from this nightm... 2009-05-07 12:28:34.000000 Old enough to know better, but too smart to ca... 174 Melbourne, Australia 13Ladolcevita
99980 2017-01-29 04:44:48.000000 2050 ["MAGA"] 825565335570968576 @KellyannePolls is really doing a reverse Nann... 2016-11-26 20:00:38.000000 Real News For The New Resistance 1304 Not Trump's America UniReEditor
99981 2017-01-29 04:44:49.000000 292 [] 825565339694018560 This is such a stupid ass, inapplicable metaph... 2014-03-09 04:03:13.000000 EHS '17 388 Lorton, VA ZaineRehman
99982 2017-01-29 04:44:50.000000 435 ["WakeUpAmerica", "LawAndOrder", "MAGA", "Amer... 825565342512603136 @HillaryClinton #WakeUpAmerica #LawAndOrder #M... 2015-06-14 16:10:02.000000 http://greatagain.gov 922 Pennsylvania, USA DavidWeingust
99983 2017-01-29 04:44:50.000000 1244 ["MAGA"] 825565342617317376 So thankful to have adults back in power...#MAGA 2015-07-23 15:03:35.000000 Christian...Conservative...Husband...Family...... 969 None imanewman442
99984 2017-01-29 04:44:51.000000 298 [] 825565344479580160 shut up toyota legume https://t.co/pugeqymzVG 2014-03-18 14:01:49.000000 feel the fear and do it anyways 509 the beach katherinemozi
99985 2017-01-29 04:44:51.000000 53 ["MAGA", "MuslimBan"] 825565346744643584 @potus #MAGA #MuslimBan Not on ban: Saudi Arab... 2010-03-16 02:24:09.000000 Overseas Yankee patriot 9 The Banana Republic of Miami kimtorahn
99986 2017-01-29 04:44:53.000000 2851 ["tcot", "pjnet"] 825565355171016704 The latest The Dryer Report! https://t.co/nMnK... 2011-10-12 00:37:00.000000 MSgt USAF (Ret) http://www.conservativesysdica... 2649 NW Florida joh2guy
99987 2017-01-29 04:44:54.000000 165 ["MAGA"] 825565360413868032 @kumailn This is actually such a stupid statem... 2016-08-17 20:37:46.000000 Baseball. Politics.Israel National Team, AOB 65 Israel zevmoore613
99988 2017-01-29 04:44:55.000000 129 ["MAGA", "LockHerUp", "pizzagate", "TrumpTrain... 825565364427698176 Refugee's = Higher Taxes! #MAGA #LockHerUp #pi... 2012-08-19 18:37:56.000000 None 259 None sealeney
99989 2017-01-29 04:44:57.000000 1955 ["NAACP", "imageawards", "CivilRights", "Leade... 825565370849300480 @NAACP 3/3 #NAACP not a good look #imageawar... 2012-03-23 14:42:15.000000 Feminist Poeta Writer Educator Reiki Practione... 1060 Bronx, NY LaPoetaMariposa
9999 2017-01-29 02:24:48.000000 698 ["MuslimBan"] 825530103375548416 .@RepWalterJones your silence with regards Tru... 2011-01-05 22:33:41.000000 Vermonter in NC, out of shape cyclist, man sho... 181 New Bern, NC keylor_halbur
99990 2017-01-29 04:44:57.000000 57 [] 825565371008704512 President Trump knows its not a 9 to 5 job! ht... 2011-12-30 18:58:31.000000 Just a girl and her computer, how could that p... 72 Nyack, NY BettyPinup
99991 2017-01-29 04:44:57.000000 114 ["AmericaFirst", "POTUS"] 825565371469959168 @d_jaishankar #AmericaFirst American people ha... 2015-10-17 17:23:59.000000 Donald Trump Support Account. #AmericaFirst #M... 159 Washington DC RealDTrump2016
99992 2017-01-29 04:44:57.000000 90 ["MAGA"] 825565372757708800 @Uber, Stay Strong. Dont cave-in to these fasc... 2017-01-12 13:54:21.000000 Namaste. LEGAL Immigrant from Bangladesh; Repu... 77 None kaminoneh
99993 2017-01-29 04:44:58.000000 19443 ["TheResistance", "TrumpLeaks", "MuslimBan", "... 825565374473179136 #TheResistance #TrumpLeaks #MuslimBan #NoBanNo... 2009-06-01 13:40:08.000000 Artist 24311 New York City, USA tamilartist
99994 2017-01-29 04:44:58.000000 317 ["SaturdayNightLive", "trump", "MAGA"] 825565376096374784 The Trump and Pence imposters on #SaturdayNigh... 2011-11-15 04:45:32.000000 337 | Second Amendment Supporter | Jesus❤️ 271 Sulphur, LA jessefontenot_2
99995 2017-01-29 04:44:59.000000 1624 ["MAGA", "MAFA"] 825565379623792640 @Luvvie To secure USA, not jihadists pretendin... 2011-12-16 16:54:43.000000 TRUST NEVER GOES OUT OF STYLE 1386 None TerryHaas1
99996 2017-01-29 04:45:00.000000 870 ["NoMuslimBan"] 825565385999032320 Yet, a FEDERAL Judge just smacked you and you... 2016-06-10 04:56:24.000000 Calling out the lies of a demagogue, one twee... 1129 The USA truth_trumpet
99997 2017-01-29 04:45:01.000000 821 ["Trumpcare", "PresidentTrump", "MAGA", "priva... 825565386884001792 Euro wobbles after Italian referendum https://... 2015-11-23 09:31:45.000000 Get the latest breaking news as they happen.CA... 971 Global CNNsWorld
99998 2017-01-29 04:45:01.000000 356 ["boycottoscar"] 825565386326364160 Couldn't agree more!! #boycottoscar https://t.... 2016-12-15 16:33:47.000000 None 189 Dallas,Tx badassbarry
99999 2017-01-29 04:45:01.000000 817 ["liberalsRSoStupid"] 825565388914229248 #liberalsRSoStupid https://t.co/NhPLknT2Kf 2013-09-11 15:18:14.000000 Save America Vote Trump 952 None LAMOONLYNN

116526 rows × 10 columns


In [2]:
from pprint import pprint 
print('Top Tweeters')
user_tweet_counts = tweets['user_name'].value_counts()
pprint(user_tweet_counts[:20])

hi_tweeters = user_tweet_counts[user_tweet_counts > 20]
plt.title('High volume tweeters tweet counts')
plt.hist(hi_tweeters, bins = 20)
plt.show()

lo_tweeters = user_tweet_counts[user_tweet_counts <= 20]
plt.title('Lo volume tweeters tweet counts')
plt.hist(lo_tweeters, bins = 20)
plt.show()


Top Tweeters
CybersMonday       781
WebDesignEA        702
wikitrendsUS       691
Ratical2017        663
dreamedofdust      635
CNNsWorld          582
SteamDevelopers    551
rickybobby90210    210
OverTheMoonbat     201
toby_dorena        168
drumpfshit360      151
TheLifeVote        148
heytootssweet      146
DJTPepePoTUS       138
DealzofAmazon      137
grade12jobs        134
63red              131
maga_zine_usa      131
timothypwoodwa1    127
TrumpBasura        126
Name: user_name, dtype: int64

In [3]:
def total_tweet_count(tweets):
    return len(tweets)

def unique_tweets(tweets):
    return tweets['text'].unique()

def unique_tweet_count(tweets):
    return len(unique_tweets(tweets))

def unique_users(tweets):
    return tweets['user_name'].unique()

def unique_users_count(tweets):
    return len(unique_users(tweets))

print(str(total_tweet_count(tweets)) + " total tweets")

print(str(unique_tweet_count(tweets)) + " unique tweets")

print(str(unique_users_count(tweets)) + " unique user_names")


116526 total tweets
74616 unique tweets
49404 unique user_names

In [4]:
def hashtags_table(tweets):
    hashtags= {}
    for row in tweets['hashtags'].unique():
        row = eval(row)
        for tag in row:
            tag = tag.lower()
            if tag not in hashtags:
                hashtags[tag] = 1
            else:
                hashtags[tag] = hashtags[tag] + 1
    hashtagspd = pd.DataFrame(list(hashtags.items()), columns=['hashtag', 'count']).sort_values('count', ascending=False)
    return hashtagspd
hashtags = hashtags_table(tweets)
print("Top 20 hashtags")
pprint(hashtags[:20])


Top 20 hashtags
              hashtag  count
0           muslimban   9325
7                maga   3000
9                aclu   2174
25        nobannowall   1605
18              trump   1390
66             resist   1276
5                tcot    817
13       americafirst    802
57              noban    533
14   muslimbanprotest    503
45      theresistance    483
114   refugeeswelcome    360
113       nomuslimban    351
49        resisttrump    301
2        jfkterminal4    299
184    notmypresident    281
77         resistance    246
28                usa    233
170      buildthewall    226
43               ccot    211

In [ ]: