Python – Retrieve latest Covid-19 World Data using COVID19Py library
COVID19Py Library retrieves the latest data revolving around the Covid-19 pandemic. This Covid-19 World Dataset is hosted at the John Hopkins University servers.
To install the library, execute below command in your system command line:
pip install COVID19Py
The library provides the following methods:
- getAll(): Retrieve the entire dataset as a JSON
- getLatest(): Get the latest stats of confirmed cases, recoveries and deaths
- getLocations(): Get the locations where Covid-19 cases exist
- getLatestChanges(): Look for any changes since you last retrieved the data
Below example illustrate the above methods:
Example:
Python3
# import given packageimport COVID19Py # Create an object,# specify data source as JHU Serverscovid = COVID19Py.COVID19(data_source = "jhu") # Retrieve all Data# in the form of jsondata = covid.getAll() # Enormous Data will be returnedprint("Data", data) # Get the latest datalatest = covid.getLatest()print("Latest Data", latest) # Get Locations where covid cases exist# Can be Ranked by 'confirmed' cases,# number of 'deaths' or# number of 'recovered' patientslocations = covid.getLocations(timelines = True, rank_by = 'confirmed')print("Locations", locations) # Check for any changes since# data was last retrievedchanges = covid.getLatestChanges() # Printing changes, if anyprint("Changes since last visit", changes) |
Output:
Data: Enormous data returned in the json form; this screenshot represents just the first few lines of the data.
Country-wise Covid Data in the form of nested dictionaries
Latest Data: Latest numbers related to Covid19 (Globally)
Global Covid19 Numbers
Location Data: Enormous location-wise Covid Data will be return in json form.This screenshot represents the first few lines.
Location Data
Changes since Last Visit: Currently all 0.
Changes since last visit



