CSV Binary Hacks
CSV Binary Hacks
• 4 min read
import pandas as pd
#read csv and sort 'Duration' largest to smallest
df = pd.read_csv('files/covid19_tweets.csv').sort_values(by=['user_location'], ascending=False)
print("--Top 10 User Locations---------")
print(df.head(10))
print("--Bottom 10 User Locations------")
print(df.tail(10))
--Top 10 User Locations--------- user_name user_location \ 144155 🐝BeeHappy🐝 🪐 2572 ✊Franc-Tireur🗽 🪐 11618 🐝BeeHappy🐝 🪐 11692 🐝BeeHappy🐝 🪐 11869 🐝BeeHappy🐝 🪐 135778 Steffen, 👨🏼✈️ 🦠➕✈️ = 🚫 🦠Grounded 90341 Petrius Off-Road 🦅💛💛💙❤🌋 23145 🏳️🌈ÐΛⱤƬⱧ §ⱠӨ₮Я🇪🇸🇮🇪🏴🇬🇧🇺🇸 🦄🌈❤️🧡💛💚💙💜🌈🦄 109189 🏳️🌈ÐΛⱤƬⱧ §ⱠӨ₮Я🇪🇸🇮🇪🏴🇬🇧🇺🇸 🦄🌈❤️🧡💛💚💙💜🌈🦄 27153 🏳️🌈ÐΛⱤƬⱧ §ⱠӨ₮Я🇪🇸🇮🇪🏴🇬🇧🇺🇸 🦄🌈❤️🧡💛💚💙💜🌈🦄 user_description \ 144155 🏝🏖🏔 2572 Committed to getting into #GoodTrouble #ICantB... 11618 🏝🏖🏔 11692 🏝🏖🏔 11869 🏝🏖🏔 135778 A380 Driver, left handed and seated. Living i... 90341 Calisthenics Athlete 🔥Ο πόνος μεταμορφώνει τον... 23145 ᗰᗩᑎᗪᗩᒪOᖇIᗩᑎ ᔕITᕼ ᒪOᖇᗪ Oᖴ ᔕᑎᗩᖇKᗩᔕᗰ ~ᗪEᗰIGEᑎᗪEᖇ ... 109189 ~ᗪEᗰIGEᑎᗪEᖇ ᑭᗩᑎᖇOᗰᗩᑎTIᑕ ᒪEᔕᗷIᗩᑎ~ ~ᔕᕼE/TᕼEY ~ G... 27153 ᗰᗩᑎᗪᗩᒪOᖇIᗩᑎ ᔕITᕼ ᒪOᖇᗪ Oᖴ ᔕᑎᗩᖇKᗩᔕᗰ ~ᗪEᗰIGEᑎᗪEᖇ ... user_created user_followers user_friends user_favourites \ 144155 2020-01-24 19:49:32 11 52 1140 2572 2014-10-28 15:00:14 1887 5001 239113 11618 2020-01-24 19:49:32 10 53 1103 11692 2020-01-24 19:49:32 10 53 1103 11869 2020-01-24 19:49:32 10 53 1103 135778 2015-11-26 09:47:38 3190 351 3900 90341 2020-07-05 16:12:42 1 0 1 23145 2012-01-10 16:49:20 286 332 29221 109189 2012-01-10 16:49:20 305 357 30397 27153 2012-01-10 16:49:20 288 335 29289 user_verified date \ 144155 False 2020-08-17 05:53:54 2572 False 2020-07-25 10:56:42 11618 False 2020-07-25 04:25:22 11692 False 2020-07-25 04:20:45 11869 False 2020-07-25 04:11:40 135778 False 2020-08-16 06:34:27 90341 False 2020-08-09 09:16:34 23145 False 2020-07-26 03:47:49 109189 False 2020-08-11 07:23:17 27153 False 2020-07-27 05:38:33 text \ 144155 @khaleejtimes @SonuSood @SonuSood thank you fo... 2572 @Salacia_sea @kylegriffin1 It’s way beyond rig... 11618 @gmanews @WHO @WHOPhilippines @senatePH @sotto... 11692 @gmanews @WHO @WHOPhilippines @senatePH @sotto... 11869 @gmanews @WHO @WHOPhilippines @senatePH @sotto... 135778 HAM & FRA Airport are looking much differe... 90341 Magis quam centum dies sine pandemic #COVID19\... 23145 #MAGAgonnaMAGAt 🙄Fauci deserves better! These ... 109189 College football players need to be safe! If t... 27153 @davenewworld_2 It's not just there... 45 minu... hashtags source is_retweet 144155 NaN Twitter for iPhone False 2572 ['AnthonyFauci', 'COVID19'] Twitter for iPhone False 11618 NaN Twitter for iPhone False 11692 NaN Twitter for iPhone False 11869 NaN Twitter for iPhone False 135778 ['Covid19'] Tweetbot for iΟS False 90341 ['COVID19', 'coronavirus'] Twitter for Android False 23145 ['MAGAgonnaMAGAt'] Twitter for iPhone False 109189 ['COVID19'] Twitter for iPhone False 27153 NaN Twitter for iPhone False --Duration Bottom 10------ user_name user_location \ 179057 Elizabeth Bomberg NaN 179059 karen ƪ(‾.‾“)┐ NaN 179062 Truth Matter-2/律政悟空,IForYou NaN 179063 IL State Med Society NaN 179064 JustMe #DefundPolice #AbolishICE/Prisons/Police NaN 179083 Auntie Kittie NaN 179091 🦋 ROGUE 🦋 NaN 179092 claudia fernandez NaN 179097 rainmaker NaN 179098 John Geer NaN user_description \ 179057 Professor of Politics, University of Edinburgh... 179059 We will not be silenced 💛💬\n• 12.18 ✨\n• anime... 179062 I suggested MagnitskyAct to sanction HK offici... 179063 Illinois State Medical Society: doctors workin... 179064 I care about too many things. #Academic-ish #C... 179083 I'm the auntie you always wished you had. If ... 179091 May all aching hearts find their way there thr... 179092 NaN 179097 NaN 179098 #StayAtHome #StayAtHomeSaveLifes #MaskUp \nFor... user_created user_followers user_friends user_favourites \ 179057 2016-08-08 06:52:35 802 80 682 179059 2019-09-06 23:04:55 25 52 3549 179062 2019-12-21 14:02:02 140 56 2364 179063 2008-10-29 18:31:28 2758 798 744 179064 2006-10-25 12:00:29 694 3423 42289 179083 2019-12-25 18:36:22 888 545 33 179091 2017-01-30 07:38:23 628 386 14845 179092 2015-07-02 23:07:03 68 192 2455 179097 2017-08-16 22:12:17 709 1158 95006 179098 2020-04-18 01:55:14 61 168 10817 user_verified date \ 179057 False 2020-08-29 19:46:36 179059 False 2020-08-29 19:46:19 179062 False 2020-08-29 19:46:02 179063 False 2020-08-29 19:46:01 179064 False 2020-08-29 19:46:00 179083 False 2020-08-29 19:45:02 179091 False 2020-08-29 19:44:51 179092 False 2020-08-29 19:44:49 179097 False 2020-08-29 19:44:35 179098 False 2020-08-29 19:44:34 text \ 179057 Thanks @edbookfest for this super #climate tal... 179059 @realDonaldTrump Just like the double of amoun... 179062 📢💥‼️#COVID19 #HerdImmunity, the smartest and c... 179063 .@Illinois_Alma’s #COVID19 testing plan is so ... 179064 Tell Congress that 9 in 10 people want our ele... 179083 Just a quick note for my lovely members. Soci... 179091 @dougmillsnyt @realDonaldTrump @FLOTUS "The #T... 179092 @politvidchannel The Trump Administration's In... 179097 @politvidchannel Just not the lives of #COVID1... 179098 Report #COVID19 outbreaks in K-12 schools here... hashtags \ 179057 ['climate'] 179059 ['COVID19'] 179062 ['COVID19', 'HerdImmunity'] 179063 ['COVID19'] 179064 ['housingstability', 'coronavirus'] 179083 NaN 179091 ['Trump'] 179092 ['COVID'] 179097 ['COVID19', 'coronavirus', 'TrumpVirus'] 179098 ['COVID19', 'CloseTheSchools', 'KeepTheSchools... source is_retweet 179057 Twitter Web App False 179059 Twitter for Android False 179062 Twitter Web App False 179063 Buffer False 179064 Twitter Web App False 179083 Sprout Social False 179091 Twitter for Android False 179092 Twitter Web App False 179097 Twitter for Android False 179098 Twitter Web App False
I used pandas to work with the file. I wanted to use selection methods (selecting top 10 and bottom 10 locations) since I wanted to check for any sort of recent locations that people have been tweeting about, and then checked the bottom 10 locations to check for any similar trends occurring at an earlier time. Pandas is very useful for this, as it is easy to filter by category in a CSV as such that is labeled by column.