Skip to content

About

Streams COVID-19 tweets into PostgreSQL and analyses topics and sentiment in Python

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What were people tweeting about COVID-19 during India's second wave?

Cover

A pipeline that streams live tweets from the Twitter API into PostgreSQL, then cleans, scores and summarises them in Python.

Most frequent hashtags in the streamed tweets

Project background

Social media gives a fast, unprompted read on public mood during a health crisis, well before surveys catch up. This project captures COVID-19 tweets as they are posted and asks what people were talking about and how they felt.

The work covers three areas:

  • Data engineering: stream tweets in real time and store them in a relational model
  • Text processing: clean tweets and score sentiment with TextBlob
  • Topic signals: surface the most common words and hashtags

Links to the technical work:

Data structure and initial checks

Tweets matching "Covid" or "covid-19" were streamed for a five-minute window on 18 April 2021 (UTC) through Tweepy and written to a local PostgreSQL database with three tables:

Table Grain Key columns
TwitterUser one row per user user_id (primary key), user_name
TwitterTweet one row per tweet tweet_id (primary key), tweet, retweet_count, user_id (foreign key)
TwitterEntity one row per hashtag in a tweet id, tweet_id (foreign key), hashtag

Before analysis each tweet had links, mentions and non-alphabetic characters removed, was lemmatised and lower-cased.

Executive summary

In the stream window the conversation was dominated by India's second wave: #COVID19India was the second most frequent hashtag after #COVID19, and the most common words were "covid", "people", "hospital", "vaccine" and "india". A student campaign to postpone exams (#POSTPONE_SSC_CHSL) was the third most used hashtag, showing how quickly a crisis spreads into everyday concerns.

Word cloud of cleaned tweet text

Insights deep dive

What people talked about

  • Healthcare pressure led the vocabulary. "Hospital", "patient", "help", "please" and "death" sit among the largest words, consistent with appeals for beds and oxygen at the time.
  • Vaccination was already a major thread. "Vaccine", "vaccination" and "appointment" appear prominently, alongside "lockdown" and "rally".

Hashtags

  • #COVID19 (about 26 uses), #COVID19India (about 24) and #POSTPONE_SSC_CHSL (about 22) were the top three, read from the chart of the 15 most frequent hashtags.
  • Spelling variants split the signal. #COVID19, #covid, #Covid and #Covid_19 are counted separately, so the true share of generic COVID tags is higher than any single bar.

Sentiment

  • Each tweet is scored positive, neutral or negative from TextBlob polarity (above, at or below zero). The notebook assigns the scores but does not save a summary of the split, so no share is reported here.

Recommendations

For a public health communications team monitoring social channels:

  • Hashtag variants fragment the counts. Normalise case and spelling before ranking topics.
  • A five-minute window reflects one moment and one region's news cycle. Stream on a schedule across days and store the timestamp to track change over time.
  • Lexicon scores miss sarcasm and pleas for help. Validate TextBlob against a hand-labelled sample, or use a model trained on social media text, before reporting sentiment shares.

Assumptions and caveats

  • Short, single snapshot: five minutes of English-language tweets on one day; results describe that window, not the pandemic overall.
  • Keyword filter: only tweets containing "Covid" or "covid-19" were captured.
  • Hashtag counts are read from the chart, as the notebook does not print them as text.
  • Outputs cleared for privacy: printed tables that contained Twitter user IDs, tweet IDs and tweet text were removed from the published notebook. The charts are kept.
  • API changes: the code uses the Tweepy 3 streaming interface and the standard Twitter API, which no longer work as written.

Technical detail

  • How to run it and the table definitions: docs/SETUP.md
  • Credentials are read from environment variables; none are stored in the repository.

About

Streams COVID-19 tweets into PostgreSQL and analyses topics and sentiment in Python

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages