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 package import COVID19Py # Create an object, # specify data source as JHU Servers covid = COVID19Py.COVID19(data_source = "jhu" ) # Retrieve all Data # in the form of json data = covid.getAll() # Enormous Data will be returned print ( "Data" , data) # Get the latest data latest = 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' patients locations = covid.getLocations(timelines = True , rank_by = 'confirmed' ) print ( "Locations" , locations) # Check for any changes since # data was last retrieved changes = covid.getLatestChanges() # Printing changes, if any print ( "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.
Latest Data: Latest numbers related to Covid19 (Globally)
Location Data: Enormous location-wise Covid Data will be return in json form.This screenshot represents the first few lines.
Changes since Last Visit: Currently all 0.