Trace the Impacts of Omicron on Colab

PropTech@ecyY
6 min readDec 15, 2021

When a large part of the world decided to ‘live with the virus’ and hoping that the vaccine can turn the pandemic into a common flu such that the death rate can be contained (Yiu, 2021), a new variant broke out in South Africa in November, which the WHO coins it Omicron. It triggered a global stock market crash on the Black Friday.

So far, it has already been three weeks since the announcement of the variant and it has been reported to have spread to many countries around the world. Some studies have found that although Omicron has a vigorous spread, but the symptoms are mild and the death rate is not as high as that of Delta.

However, the first death of an Omicron patient occurred in the UK yesterday. It was reported that, among the confirmed cases in London, more than 44% of the patients were infected with the Omicron virus. It may be too early to make any conclusions as just a three-week period is not long enough to observe the impacts. It may take a longer time to tell the impacts on death rate of the Omicron. This article aims to provide a program on Colab to keep track of the impacts of the virus for a longer time, including (a) the number of daily confirmed cases per million people, (b) the number of daily confirmed deaths per million people, and (c) the number of daily confirmed deaths to the number of daily confirmed cases ratio, ND/NC.

Currently, no statistics on the ratio are provided publicly, even though the number of confirmed cases and the number of confirmed deaths are separately provided. It may be easy to calculate the ratio, but then it requires daily downloading of updated data every day to calculate and plot the time series. It is more efficient to write a program on Colab to download the data directly to calculate and plot the graphs automatically with just one press.

As South Africa and the United Kingdom are two of the spots of the earliest outbreaks. This article tries to find the ratios of ND/NC in South Africa and the United Kingdom to track the lethality of the Omicron.

Calculate ND/NC with Our World in Data in Colab

We use the full dataset from Our World in Data (2021) which provides daily updated data of each country, including the number of confirmed deaths and the number of confirmed cases per million people per country per day, but no data on the ND/NC ratio is provided.

The following is a simple program written in Python run on Colab, it just requires 40 lines of codes. The chart can be automatically updated at any time by running the program. The program is adapted from Sepdek (2020). For detailed discussions of the program, please refer to Sepdek (2020).

A demonstration of running the program on colab is detailed at my Youtube video at https://youtu.be/6DSW8mfeABA

Colab program

import pandas as pd
from google.colab import files
from datetime import datetime
from pandas.plotting import register_matplotlib_converters
from matplotlib import dates as dts
from matplotlib import pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
url = 'https://covid.ourworldindata.org/data/owid-covid-data.csv' #data source url
data = pd.read_csv(url,parse_dates=['date'],index_col=['date']) #read the csv file
fig = plt.figure(figsize=(25,6)) # define the figure and initialise it to a size
ax1 = fig.add_subplot( 1, 3, 1) # define left subplot ax1
ax1.set_title( 'Confirmed new cases per million')
ax1.set_xlabel( 'Time')
ax1.set_ylabel( 'Confirmed new cases per million')
ax2 = fig.add_subplot( 1, 3, 2) # define middle subplot ax2
ax2.set_title( 'Confirmed new deaths per million')
ax2.set_xlabel( 'Time')
ax2.set_ylabel( 'Confirmed new deaths per million')
ax3 = fig.add_subplot( 1, 3, 3) # define right subplot ax3
ax3.set_title( 'Confirmed new deaths to new cases ratio')
ax3.set_xlabel( 'Time')
ax3.set_ylabel( 'Confirmed new deaths to new cases ratio')
locations = ['South Africa', 'United Kingdom']
# run the loop for the countries chosen by specifying locations = ['xxx', 'yyy']
for loc in locations:
df = data.query( "location=='"+loc+"'") # filter the data for a particular country
x = df.index # get the date field (now the 'index')
ax1.plot( x, df.new_cases_per_million, label=loc) # create scatter plots
ax2.plot( x, df.new_deaths_per_million, label=loc)
ax3.plot( x, df.new_deaths/df.new_cases, label=loc)
ax1.legend(loc='best') # display a legend for both subplots
ax2.legend(loc='best')
ax3.legend(loc='best')
plt.tight_layout() # maximise the space the graphs will take inside the browser window
days = dts.DayLocator() # activate the minor X axis ticks to represent days
ax1.xaxis.set_minor_locator(days)
ax2.xaxis.set_minor_locator(days)
ax3.xaxis.set_minor_locator(days)
ax3.yaxis.set_view_interval(0, 0.3, True) # set the yaxis min max to exclude outliners
plt.show() # display the figure

*it is available at the following Github: https://github.com/Chung-collab/GREAT-LAB/blob/main/Omicron.ipynb

ND/NC chart

Figure 1 shows the three charts produced by the above program. Figure 1a on the left is the number of daily confirmed new cases per million people of South Africa (blue line) and the United Kingdom (red line). The latest update date is December 13, 2021.

Figure 1 Program results

Figure 1a (left chart) shows that both countries have a sharp rebound in the number of daily confirmed new cases per million people in recent days. Figure 1b (middle chart) shows that the number of daily confirmed new deaths per million people, which do not seem to have any commensurate rebounds as the number of confirmed cases. Figure 1c (right chart) shows the ND/NC ratio. The recent ND/NC ratios of the two countries are still at a relatively low level, reflecting that even if the number of confirmed cases has risen sharply, the number of confirmed deaths have not risen with the increase in confirmed cases. It may take more time to show the impacts and this program is good to track the trends in the coming future.

It is also very user-friendly to include or exclude which country in the charts. Just enter the names of the chosen countries in the program line indicating the locations in bracket and quotation, separated by comma. For a detailed demonstration, you can watch the short video https://youtu.be/6DSW8mfeABA

Tracking with Pivot Table in Excel

If you prefer to update and plot manually the data daily, you can also draw graphs in Excel. However, since the data file provided by Our World in Data (2021) is in Stack format, you must use the Pivot Table function to create a matrix data table to draw the graphs. Figure 2 shows the chart plotted by the Pivot Table function of Excel on the number of daily new deaths per million people of the two countries, which is roughly the same as Figure 1b.

Figure 2 The daily number of new deaths in the two countries

It is easier to analyse the rate of change of the time series in Excel. For example, Figure 3 shows the Pivot Table data of the recent three months of the two countries, i.e. October, November and December 2021 (up to December 13th). The data reflects that as of December 13, the number of new confirmed cases in South Africa has risen sharply by 678% in comparison with the whole month of November, but the ND/NC ratio has continued to drop from 2.4% to 0.1%.

Figure 3 The number of daily new confirmed cases per million people, the number of daily new deaths per million people, and the ND/NC ratio of the two countries in October, November and December 2021 (up to December 13), and their monthly growth rates.

References:

Our World in Data (2021) Statistics and Research, https://ourworldindata.org/covid-deaths

Sepdek (2020) Analysis of Live COVID-19 Data-a Python/Colab Approach, March 29. http://georgepavlides.info/analysis-of-live-covid-19-data-a-python-colab-approach/

Yiu, C.Y. (2021) COVID Has Killed More Than Five Million People in the World so far, Medium, Oct 30. https://medium.com/discourse/covid-has-killed-more-than-five-million-people-in-the-world-so-far-62b9054bbd4a

--

--