Calculating the Reproduction Number (Ro) of COVID-19 in India and Visualizing the same using Geopandas and Matplotlib
Introduction
The disease COVID-19, caused by the novel coronavirus SARS-CoV-2, reached Indian shores in late January through Italian tourists. Since then, it is confirmed to have infected at least 4289 lives as of 5 April, 2020. Governments across the country have intervented by asking its residents to social distance themselves from others through a lockdown, testing of symptomatic individuals and tracing their contacts.
In epidemiology, the basic reproduction number of an infection (Ro — pronounced R-naught) can be thought of as the expected number of cases directly generated by one case in a population where all individuals are susceptible to infection. The definition describes the state where no other individuals are infected or immunized.
In this article, the python code to compute Ro for each state/union territory of India, and visualize the same, is explained.
Source of Data
Time series data of confirmed cases for each state is obtained from the google doc hosted by the case tracking site https://covid19india.org.
Calculating Ro
Ro is calculated by the formula:
EXP((LN(Population/((1/(case[current]/(case[start]*Population)))-1)))/(current-start))
where,
a. LN is the natural logarithm;
b. case[start] is the case count on starting day;
c. case[current] be the case count on current
d. Population is the population of the state/UT
e. current = no. of days from the start of the outbreak and start = 0
Python Code
Importing the case time series file
At first the case time series file is imported.
Declaring the hyperparameters
Next, the hyperparameters are set. These are the lookback value, based on which the Ro is calculated and the population of India.
Calculating Ro for each State/UT
Lists are declared, where the names of states/UTs and their Ro is stored. Also, based on the computed Ro, a prediction of the number of cumulative cases is made for the next day.
Writing the Ro to DataFrame
The names of the states/UTs, their Ro and predicted cumulative cases are written to a new dataframe which will be used for geospatial visualization.
Importing Geopandas and Shapefile
In order to visualize the Ro for each state/UT, the geopandas library is downloaded using the command:
pip install geopandas
If you encounter difficulties while downloading the package due to incompatible dependencies, then this guide should help.
Next, the shapefile for India is downloaded from here.
The shapefiles will be downloaded as a zipped folder containing various categories of files. The files of format .shp, .shx, .dbf, .prj and .cpg, need to be extracted to the working directory.
Merging the geodataframe and DataFrame
The geodataframe and dataframe are merged on the feature of state/UT names.
Generating and Displaying the Chloropleth by the Ro
Finally, the chloropleth map is built on the basis of Ro and displayed.
The raw files, code and notebook referred to in this article can be found at this github repo.
— — -BEGIN BITCOIN SIGNED MESSAGE — — -
Calculating the Reproduction Number (Ro) of COVID-19 in India and Visualizing the same using Geopandas and Matplotlib
— — -BEGIN SIGNATURE — — -
1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN
HCCN5IwW2xsD/cumL0iUowS4ZFyOQmTa3Qx2YqOykwD2SICi2CqkLFhrkngcIiyA/0uisK8F+TuR0++/OkhMBuA=
— — -END BITCOIN SIGNED MESSAGE — — -