The CovidCases World sub-classes version 5.2: ECDC, WHO and OWID
CovidCasesECDC, CovidCasesWHO and CovidCasesOWID class documentation#
All three classes behave the same according to their base class CovidCases. The usage is pretty simple. In a first step you have to download the actual data and afterwards you create an instance of the class which will load the data and initialize the parent class.
Finally you call methods of the base class to access the data for a given list of countries. It is interesting to compare the quality of the different data sources. You may want to read our report here.
Even if the quality of the Our World in Data dataset is not as good as the one of the WHO the OWID dataset has a big advantage of containing vaccination data as well. Refer to the CovidCases base class for more information about the vaccination data.
Here are the function definitions for all of these classes in detail, they are the same for all of them:
@staticmethod def download_CSV_file():
Automatically downloads the database file from the data provider if it doesn’t exists already. The data provider can be the ECDC, the
WHO or Our World In Data. The function needs to be called in a
try-except block as it may throw a
FileNotFoundError or an
IOError exception. The function will check if the file YYYY-MM-DD-XXX-db.csv already exists in the covid-19-analysis/data folder. XXX refers to a shortcut to identify the data source. If so the function will return the fully qualified filename. If not it will connect to the data provider server to download the file and return its filename as well.
def __init__(self, filename):
The constructor of the class just takes the fully qualified filename containing the csv downloaded from the data provider. The class will keep a copy of all data in the file.
DataFrame having just two columns
GeoName. You may want to store the returned
DataFrame as a csv file. The function has to be implemented by all sub-classes.
DataFrame containing information about the data source. The
DataFrame holds 3 columns:
InfoFullName: The full name of the data source
InfoShortName: A shortname for the data source
InfoLink: The link to get the data
The function has to be implemented by all sub-classes.
def review_geoid_list(self, geoIDs):
Returns a corrected version of the given geoID list to ensure that mismatches like UK versus GB are corrected by the sub-class. For instance: If the given list contains [‘DE’, ‘UK’] the function will return [‘DE’, ‘GB’] to correct the wrong UK with the ISO-3166-alpha_2 conformal GB.
The following functions help you to create so called heatmaps to show values represented by colors on a world map. In order
to plot the world maps we need to know which ISO2 GeoID belongs to which country. The following static methods are all
returning a list of ISO2 GeoIDs that are understood by the Pygal world map package. This is needed as Pygal uses different country codes as e.g. the ECDC and
some countries are not available in Pygal. Also be aware that the WHO writes the codes uppercase while Pygal asks
for lowercase codes. England is called gb in Pygal and UK in the ECDC data. This is similar to Greece which is called gr in Pygal and EL in the ECDC data.
The following methods returns the intersection of the country codes the data provider uses and those that are understood by Pygal, grouped by the specified continent. Once a
DataFrame have been generated for these countries the
CovidMap class can be used to generate a world map for you. Refer to the code in the Juyper Notebook to see how to do this.
def get_pygal_[continent]_geoid_list(): def get_pygal_[continent]_geoid_string_list():
The upper methods returns an array of the country codes and the lower method a string with all codes comma separated. The field
[continent] could be one of the following: