Skip to main content

A fast, powerful, and flexible way to get up to date COVID-19 data for any major city, state, country, and total world wide data, with just one line of code

Project description

COVID19-Data

Build Status GitHub issues PyPI - Python Version GitHub release (latest by date) PyPI GitHub release (latest by date including pre-releases)

Overview

covid19-data is a powerful and easy to use Python client for getting COVID-19 data (see sources below for more information on how data is obtained)

  • Uses a fast method of getting data
    • Does not rely on scraping sites, parsing files, or getting (old) data from a repository, so you do not depend on the repository being updated to get up to date data
  • Very fast and responsive
    • The client only gets the data once, and parses it into a search friendly format in the backend, so once the data is loaded ( ~ 1 second ), data for the World or any Country/State can be retrieved instantly
  • User friendly and simple to implement into your application
  • Very flexible and will return the data in multiple forms (read documentation section for more info)
    • Can return data as a "Class Style Object" with attributes (only requires one line of code, and is super easy to read!)
    • Can return an object with the data as attributes
    • Can return a JSON document
  • Super simplistic and lightweight and does not rely on any external python packages

Installing

covid19-data can be installed with pip:

$ pip install covid19-data

Alternatively, you can grab the latest source code from GitHub:

$ git clone git://github.com/binarynightowl/covid19_python
$ python setup.py install

Documentation

Usage

There are multiple ways of getting data with covid19-data

  1. Object/parameter style retrieval

    • Gets the data by calling the class of the desired information source and the statistics for any location. As of now, only John Hopkins University (JHU) is supported but in a future release, multiple sources will be supported.
      from covid19_data import JHU
      
      # Format: <Data Source>.<Location>.<Statistic>
      # For example to get data from John Hopkins University, review the following example:
      # JHU.China.deaths
      
      print("The number of COVID-19 recoveries in the US: " + str(JHU.US.recovered))
      print("The number of confirmed COVID-19 cases in Texas: " + str(JHU.Texas.confirmed))
      print("The number of COVID-19 deaths in California: " + str(JHU.California.deaths))
      print("The number of worldwide COVID-19 deaths: " + str(JHU.Total.deaths))
      print("The number of COVID-19 deaths in China: " + str(JHU.China.deaths))
      print("The number of COVID-19 deaths in UK: " + str(JHU.UnitedKingdom.deaths))
      
      Sample Output:
      The number of COVID-19 recoveries in the US : 685164
      The number of confirmed COVID-19 cases in Texas : 150851
      The number of COVID-19 deaths in California : 5935
      The number of worldwide COVID-19 deaths : 502947
      The number of COVID-19 deaths in China : 4641
      The number of COVID-19 recoveries in the United Kingdom : 1364
      
  2. As an object with attributes of COVID data

    • Get the data by name (note: spacing and capitalization do not matter, EX: total = covid19_data.dataByName("New York"), total = covid19_data.dataByName("newyork"), and total = covid19_data.dataByName("NEW YORK") are all interchangable)
      import covid19_data
      
      # example of how to get data by name
      # .dataByName([string of item to find: any state, country, or total amount (spacing and capitalization do not matter)])
      # object has three useful attributes: .deaths, .cases (.confirmed also works), and .recovered
      
      total = covid19_data.dataByName("Total")    # create an object for our total data
      china = covid19_data.dataByName("China")
      US = covid19_data.dataByName("US")
      new_york = covid19_data.dataByName("NewYork")
      print(total.deaths, china.recovered, US.cases)
      
      Sample Output:
      22184 74181 69246
      
    • Get the data by abbreviation (note: spacing and capitalization do not matter, EX: total = covid19_data.dataByName("New York"), total = covid19_data.dataByName("newyork"), and total = covid19_data.dataByName("NEW YORK") are all interchangable)
      import covid19_data        
      
      # example of how to get data by abbreviated name
      # .dataByNameShort([two letter string of item you want to find, can be any state])
      # object has three useful attributes: .deaths, .cases (.confirmed also works), and .recovered
      
      texas = covid19_data.dataByNameShort("TX")    # create an object for our total data
      california = covid19_data.dataByNameShort("CA")
      new_york = covid19_data.dataByNameShort("NY")
      print(texas.cases, california.deaths, new_york.cases)
      
      Sample Output:
      1353 67 33033
      
  3. As a JSON document

    • Get the json by name (note: spacing and capitalization do not matter, EX: total = covid19_data.dataByName("New York"), total = covid19_data.dataByName("newyork"), and total = covid19_data.dataByName("NEW YORK") are all interchangable)
      import covid19_data
      
      # example of how to get json by name
      # .jsonByName([string of item you want to find, can be any state, country, or total amount (spacing and capitalization do not matter)])
      # object has three useful attributes: .deaths, .cases (.confirmed also works), and .recovered
      
      total = covid19_data.jsonByName("Total")    # create an object for our total data
      china = covid19_data.jsonByName("China")
      US = covid19_data.jsonByName("US")
      new_york = covid19_data.jsonByName("NewYork")
      print(total, china, US, new_york)
      
      Sample Output::
      {'Confirmed': 492603, 'Deaths': 22184, 'Recovered': 119918}
      {'Confirmed': 81782, 'Deaths': 3291, 'Recovered': 74181, 'Active': 4310}
      {'Confirmed': 69246, 'Deaths': 1046, 'Recovered': 619, 'Active': 0}
      {'Confirmed': 33033, 'Deaths': 366, 'Recovered': 0, 'Active': 0}
      
    • Get the json by abbreviation (note: spacing and capitalization do not matter, EX: total = covid19_data.dataByName("New York"), total = covid19_data.dataByName("newyork"), and total = covid19_data.dataByName("NEW YORK") are all interchangable)
      import covid19_data
      
      # example of how to get json by abbreviated name
      # .jsonByNameShort([two letter string of item you want to find, can be any state])
      # object has three useful attributes: .deaths, .cases (.confirmed also works), and .recovered
      
      texas = covid19_data.jsonByNameShort("TX")    # create an object for our total data
      california = covid19_data.jsonByNameShort("CA")
      new_york = covid19_data.jsonByNameShort("NY")
      print(texas, california, new_york)
      
      Sample Output::
      {'Confirmed': 1353, 'Deaths': 17, 'Recovered': 0, 'Active': 0}
      {'Confirmed': 3172, 'Deaths': 67, 'Recovered': 0, 'Active': 0}
      {'Confirmed': 33033, 'Deaths': 366, 'Recovered': 0, 'Active': 0}
      

Sources

This package utilizes John Hopkins University's ArcGIS data layer to get its data. Please follow their terms of service and licensing when using their data in your application. The data layer pulls data from the following sources:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

covid19-data-1.2.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

covid19_data-1.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file covid19-data-1.2.0.tar.gz.

File metadata

  • Download URL: covid19-data-1.2.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for covid19-data-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5919e1df306674cdc4d406caff30708fa678fa89d68a2c099b52839de89d4324
MD5 6e5e1d89f9bfa97fd1015d15802c2d5f
BLAKE2b-256 dc70d5909894d7c533a04ded68042450aa88b88b215436d8c2a1bf71eee4afaa

See more details on using hashes here.

File details

Details for the file covid19_data-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: covid19_data-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for covid19_data-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9465456618568c5dbc45d72a2e537fbee4abc5bce7b9d99e0a7b951ca051ed59
MD5 010a439babc193b609386ac027a005c4
BLAKE2b-256 7ddb89ce0183491f7988a8ffa3e8c43f4d49076389f56aaa4ec2f781ee3a63db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page