I wanted to play around with Sentiment Analysis of Tweets; specifically, I wanted to try the Python TextBlob library, which has a built-in function that performs text analysis to determine if a string has a positive or negative sentiment. After pondering a bit, I decided it would be fun to search for tweets that were created specifically within the city limits of Tuscaloosa, where I am currently attending school. I wrote a script that scrapes Twitter and returns tweets by geolocation, and then uses TextBlob on the results.
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 6 15:58:58 2022
@author: austin
"""
import snscrape.modules.twitter as sntwitter #Social Network Scraping Library
import pandas as pd #so I can make a dataframe of results
from textblob import TextBlob
import csv
import time
#Tuscaloosa = geocode:33.23726448661455,-87.58279011262114,20km
query = "geocode:33.23726448661455,-87.58279011262114,20km"
tweets = []
combinedtweets = []
limit = 10000000 #set a limit on how many results I want to pull
for tweet in sntwitter.TwitterSearchScraper(query).get_items():
if len(tweets) == limit:
break
else:
# set sentiment
text = tweet.content
analysis = TextBlob(text)
if analysis.sentiment.polarity >= 0:
sentiment = 'positive'
else:
sentiment = 'negative'
tweets.append([tweet.date, tweet.user.username, tweet.content, sentiment])
df = pd.DataFrame(tweets, columns=['Date', 'User','Tweet', 'Sentiment'])
df.to_csv('twitter_scrape_results.csv') #save dataframe as csv
print("\014") #clear console
time.sleep(10)
print("CSV Successfully Created")
The results were pretty interesting (I uploaded the dataset to Kaggle if anyone is interested). It seems sentiment stays roughly the same each year, hovering around 85% positive and 15% negative. I really would have thought negative sentiment would be much higher based on my personal observations of Twitter content: makes me wonder if Tuscaloosa is an unusually happy place, or if my Twitter observations are influenced by negative bias…
In any case, perhaps a more interesting bit of data is that the total amount of Tweets seems to decline quite a bit each year. This raises the question, why are Tuscaloosians tweeting less often? I put the results into this Tableau dashboard, which displays just how steady and steep a decline there has been.
×
Update:
I decided to test a hypothesis: perhaps the high level of positive tweet sentiment is due to the fact that this is a college town, and numerous tweets were posted by official University of Alabama departments? I used OpenRefine to filter out official UA accounts, which was easy enough to do since their usernames seem to either begin with “UA_” or end with “_UA”. Surprisingly though, that didn’t change the sentiment percentages at all. I now suspect that even if you factor in all official UA Twitter accounts, you would also have to factor for the fact that a large number of Tuscaloosians work for UA (45,000 employees). I know many of my professors post UA related content using their personal Twitter accounts, and by design this content will logically slant positive.
As the famous American writer Mark Twain is believed to have once stated: “The man who does not read good books is no better than the man who can’t.” Perhaps you are an avid reader, or like most you may only read books rarely if at all. There is a great benefit however in building a quality personal library and reading from it regularly. In fact, I am going to argue that this is critically vital if you wish to be successful in your career. If you don’t start building your own personal library now, and adopt an aggressive pattern of daily reading, then you simply won’t be competitive with other prospective employees in the marketplace.
For example, I personally read 45 mins every morning, of a book that I believe will be beneficial to my career. I take Saturdays off, so that is 4.5 hours of reading a week, or 234 hours of reading per year. I average 2 books a month, or 24 books a year. Meaning that in four years, someone following this same regiment would have read 96 books in their field of study. That is a lot of self-study. And when you are interviewing for jobs, you will be up against interviewees like me who use their free time to get a leg-up on their future competition. As Amitesh Jasrotia says in a 2021 blog post for Bookjelly.com, “your library can be your armory of knowledge with which to aim at higher things in life.”
So allow me to share the many benefits of building your own personal library, how to find relevant books to buy, and what sort of books you may want to start with.
A lack of reading is a critical problem in modern society. According to a 2021 article by Pew Research, titled “Who doesn’t read books in America?”, roughly a quarter of American adults (23%) say they haven’t read a book in the past year. Maybe this describes you. You may think to yourself that you can just google any information you need. Living in the modern digital age, it is easy to get into the mindset that any question can be answered with a few keystrokes, but this simply isn’t the case. For starters, there is a lot of information that can only be found in the pages of a book. Most books have never been digitized, and books tend to explore subjects at a much greater depth than an online article or YouTube video. Some books are rare and difficult to acquire, full of information difficult to find elsewhere. It may be that reading such a book gives you an advantage over people who don’t have access to that knowledge. That is one of the reasons that I like to search for and collect rare books that are relevant to my field of study. The extra effort it takes to hunt down and read a rare book might just pay dividends in the future, when you know things that people that you are in competition with don’t. As historian Matthew Muller stated in a 2020 blog post, “collecting actual books is a great way to gain access to knowledge and preserve it over time.”
There is also a psychological difference in absorbing information from a book rather than from a computer screen. The media theorist Marshall McLuhan wrote an entire book, “The Guttenberg Galaxy”, on the power of the printed page. It’s a rare book, difficult to find. I am lucky enough to own a copy. McLuhan states in this book that when we read text off a page of a book, that our brain processes that information differently than when we absorb content through electronic mediums. In other words, the method that we take in information has a degree of influence over how we understand it. So we can’t equate googling an answer to finding answers from a book, as they are quite different things.
So why build a library and not simply check books out at your local library? There certainly is a financial benefit to using your local library, however it isn’t a great substitute for building your own library. For one, it isn’t very efficient. Every time you are ready to pick up a new book to read, or anytime you need a quick reference, you would have to jump into your car and drive to your nearest library. With the price of gas being what it is, this is quickly becoming less economical than it may have originally seemed. You are also at the mercy of what the library has in stock, which means the books most beneficial to you might not be accessible to you. Furthermore, especially niche books or truly rare books aren’t often stocked by libraries. Building your own personal library will allow you to select the books most relevant to your own needs, and you will have instant access to them 24/7.
There are lots of ways to help offset the cost of books if that is a concern. Frequenting used bookstores and searching auction sites like eBay will often allow a frugal book buyer the opportunity to amass a large collection quite economically. But how do you figure out what books to buy? There is after all an almost limitless number of books, and a finite amount of time to read them, and certainly a finite budget to spend on them. Surely it would be wise to sort through them all and make a list of the most beneficial books? Well, one way that I like to do this is my searching appropriate subreddits and forums for recommended books. The social media platform Goodreads also contains user recommended lists for any number of book subjects. Sometimes with a bit of googling you can find blog posts or YouTube videos where content creators share books that were helpful to them. I also find that as I am reading, it is often the case that an author might suggest another book to read on the subject, so I keep a notepad next to my reading chair so I can jot these recommendations down to find later.
Now you may be wondering where to start? Well, lets take my own library as an example. Your library should be unique to you and your own goals, however there will likely be a good deal of commonality with other libraries as there are certain topics and genres that have universal benefit. Your library should also reflect a diverse range of subjects, so you can be a well-rounded reader. According to Justin Brown’s 2018 blog post for IdeaPod, titled “15 incredible benefits from reading every day”, being a well-rounded reader will lead to you being better equipped to handle many of life’s challenges. I have a number of books always at hand, and they are organized by category. One shelf is entirely fiction, including a number of the classics and many science fiction and fantasy. You may think that reading fiction won’t be any help to you professionally, but I beg to differ. Fiction opens your mind to places, cultures, and circumstances. It places you in the shoes of others, and lets you explore different points of view. This experience can be beneficial to us in a lot of ways.
The next bookcase mostly contains books that are directly relevant to my career. I am an Advertising Major, so the first row contains books on Communication Theory and Media Ecology and the second row contains the most recommended books on Advertising. Then, because I am interested the data analytics side of things, we have a row of books about Programming and Databases, and a row about Math and Statistics. The last two rows are Religion.
The third bookcase is where I keep books on subjects that I find personally interesting. Including Art books, Graphic Design, and Typography on the top shelf. The next row of books are all about Economics, and finally a row of books about Politics and American History.
As you can see, there is a great deal of variety in my library. The goal is to become well-rounded in your reading, while still being relevant for your personal career goals. I implore you to begin constructing your own library, one that is inline with your own goals and aspirations, and that will give you a well-rounded base of knowledge. And as you build this library, read from it, every day. This will give you a competitive advantage that can’t be acquired adequately in any other way.