Skip to main content

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.

Release files for covid19-us 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for covid19-us 1.0.3
File Size Uploaded
covid19_us-1.0.3.tar.gz 1.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for covid19-us 1.0.3
File Interpreter ABI Platform
covid19_us-1.0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 2.0 MB

Release files / covid19_us-1.0.3.tar.gz

Download URL covid19_us-1.0.3.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
30a4f4ec8e630b4fcd3d5c22e45b6f22ed11ccf81036dde38c084a927cbe59e3
BLAKE2b-256 checksum
How to use checksums
df454a46382032c1a496bdd8e13264ddb5fd42a38aaedb69f10faaa01b6a0973
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / covid19_us-1.0.3-py2.py3-none-any.whl

Download URL covid19_us-1.0.3-py2.py3-none-any.whl
Size 1.0 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4415c09ed91e68c14d6825433030f4cd797a9f7168128ac35ec2b45c592a4b55
BLAKE2b-256 checksum
How to use checksums
4599fe8e494dfbb85e81b9cc731f74ebf40d31e0466704178c5e604250a984c1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

1 release file

1.0.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page