Skip to main content

this package provides a streamlined way to download covid data by state

Project description

covid19-us

https://img.shields.io/pypi/v/covid19_us.svg https://img.shields.io/travis/HaigangLiu/covid19-us.svg

Overview

This package aims to provide a streamlined way to download historical covid data from the United States. We support the historical data sliced by state, county and zip code through three easy-to-use APIs: download_by_state, download_by_county and download_by_zip_code.

Note that for most input variables, we support either a string or a list. For example, ‘zip_code_list’ can be either 38120 or [‘38120’, ‘02472’]. If it’s the latter case, two result sets will be concatenated and returned as a pandas dataframe.

Free software: MIT license

Features

  1. Download data by state in the United States

    download_by_state() is a function to download daily data from a given state. An example is illustrated as follows. Note that the following functions typically can accept both list type or string type. In other words, [‘SC’] and SC can be both understood as South Carolina correctly.

from covid19_us import download_by_state
sc_three_days = download_by_state(state='SC', dates=['2020-12-31', '2021-01-01', '2021-01-02'])
sc_three_days[['state', 'date', 'cases', 'deaths']]

state

date

cases

deaths

0

SC

2021-01-02 00:00:00

5211

89

1

SC

2021-01-01 00:00:00

0

0

2

SC

2020-12-31 00:00:00

4032

47

  1. Download data by county in the United States

    download_by_county() is a function to download daily data from a given county or counties. An example is illustrated as follows. We support both county name and county FIPS, a unique identifier.

from covid19_us import download_by_county
from pandas import date_range
richland_2020 = download_by_county(states='SC', counties='Richland', dates=date_range('2021-02-10', '2021-02-15'))

county

date

deaths

cases

deaths_cumulative

cases_cumulative

888738

Richland

2021-02-10 00:00:00

5

173

457

37804

888739

Richland

2021-02-11 00:00:00

3

208

460

38012

888740

Richland

2021-02-12 00:00:00

1

239

461

38251

888741

Richland

2021-02-13 00:00:00

2

239

463

38490

888742

Richland

2021-02-14 00:00:00

3

312

466

38802

888743

Richland

2021-02-15 00:00:00

6

164

472

38966

  1. download data by zip code in the united states

    download_by_zip_code() is function to download daily data from a given zip code. Again, this is not exactly count by zip code, but the county total where the zip code resides in.

from covid19_us import download_by_zip_code
tn_new_year = download_by_zip_code(zip_code_list=['38120'], dates=['2021-01-01', '2021-01-02', '2021-01-03'])

county

state

fips

date

deaths_cumulative

cases_cumulative

deaths

cases

953003

Shelby

TN

47157

2021-01-01 00:00:00

903

67800

0

602

953004

Shelby

TN

47157

2021-01-02 00:00:00

914

69798

11

1998

953005

Shelby

TN

47157

2021-01-03 00:00:00

925

70142

11

344

Credits

  • The data source is from the New York Times. The author would also like to express his gratitude for the agency’s effort to achieve outstanding journalism.

History

0.1.0 (2021-03-22)

  • First release on PyPI.

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_us-1.0.3.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

covid19_us-1.0.3-py2.py3-none-any.whl (1.0 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file covid19_us-1.0.3.tar.gz.

File metadata

  • Download URL: covid19_us-1.0.3.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

File hashes

Hashes for covid19_us-1.0.3.tar.gz
Algorithm Hash digest
SHA256 30a4f4ec8e630b4fcd3d5c22e45b6f22ed11ccf81036dde38c084a927cbe59e3
MD5 7bdb0b682691cdfbc1344817525b56a5
BLAKE2b-256 df454a46382032c1a496bdd8e13264ddb5fd42a38aaedb69f10faaa01b6a0973

See more details on using hashes here.

File details

Details for the file covid19_us-1.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: covid19_us-1.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.7

File hashes

Hashes for covid19_us-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4415c09ed91e68c14d6825433030f4cd797a9f7168128ac35ec2b45c592a4b55
MD5 d9e8428a166324c8d1ec4309bb1e0f47
BLAKE2b-256 4599fe8e494dfbb85e81b9cc731f74ebf40d31e0466704178c5e604250a984c1

See more details on using hashes here.

Supported by

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