Python – Retrieve latest Covid-19 World Data using COVID19Py library
Last Updated :
19 Aug, 2020
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 COVID19Py
covid = COVID19Py.COVID19(data_source = "jhu" )
data = covid.getAll()
print ( "Data" , data)
latest = covid.getLatest()
print ( "Latest Data" , latest)
locations = covid.getLocations(timelines = True ,
rank_by = 'confirmed' )
print ( "Locations" , locations)
changes = covid.getLatestChanges()
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.
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...