Skip to content

Commit 3e3ab0b

Browse files
authored
Merge pull request #10 from lee14257/lee14257/package-eval
Initial documentation and data fetching guide (with examples)
2 parents 8659609 + aa05f2b commit 3e3ab0b

File tree

4 files changed

+438
-67
lines changed

4 files changed

+438
-67
lines changed

docs/covidcast_examples.rst

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Basic examples
2+
--------------
3+
4+
To obtain all available sources of epidemiological data, we can use the following command:
5+
6+
>>> from delphi_epidata.request import CovidcastEpidata, EpiRange
7+
>>> epidata = CovidcastEpidata()
8+
>>> print(list(epidata.source_names))
9+
['chng-cli', 'chng-covid', 'covid-act-now', 'doctor-visits', 'fb-survey', 'google-symptoms', 'hhs', 'hospital-admissions', 'indicator-combination-cases-deaths', 'jhu-csse', 'quidel-covid-ag', 'safegraph-weekly', 'usa-facts', 'ght', 'google-survey', 'indicator-combination-nmf', 'quidel-flu', 'safegraph-daily', 'nchs-mortality']
10+
11+
12+
To obtain smoothed estimates of COVID-like illness from our symptom survey,
13+
distributed through Facebook (`fb-survey`), for every county in the United States between
14+
2020-05-01 and 2020-05-07:
15+
16+
>>> from delphi_epidata.request import EpiRange
17+
>>> apicall = epidata[("fb-survey", "smoothed_cli")].call(
18+
... 'county', "*", EpiRange(20200501, 20200507),
19+
... )
20+
EpiDataCall(endpoint=covidcast, params={'data_source': 'fb-survey', 'signals': 'smoothed_cli', 'time_type': 'day', 'time_values': '20200501-20200507', 'geo_type': 'county', 'geo_values': '*'})
21+
>>> data = apicall.df()
22+
>>> data.head()
23+
source signal geo_type geo_value time_type time_value issue lag value stderr sample_size direction missing_value missing_stderr missing_sample_size
24+
0 fb-survey smoothed_cli county 01000 day 2020-05-01 2020-09-03 125 0.825410 0.136003 1722 NaN 0 0 0
25+
1 fb-survey smoothed_cli county 01001 day 2020-05-01 2020-09-03 125 1.299425 0.967136 115 NaN 0 0 0
26+
2 fb-survey smoothed_cli county 01003 day 2020-05-01 2020-09-03 125 0.696597 0.324753 584 NaN 0 0 0
27+
3 fb-survey smoothed_cli county 01015 day 2020-05-01 2020-09-03 125 0.428271 0.548566 122 NaN 0 0 0
28+
4 fb-survey smoothed_cli county 01031 day 2020-05-01 2020-09-03 125 0.025579 0.360827 114 NaN 0 0 0
29+
30+
31+
Each row represents one observation in one county on one day. The county FIPS
32+
code is given in the ``geo_value`` column, the date in the ``time_value``
33+
column. Here ``value`` is the requested signal---in this case, the smoothed
34+
estimate of the percentage of people with COVID-like illness, based on the
35+
symptom surveys. ``stderr`` is its standard error. The ``issue`` column
36+
indicates when this data was reported; in this case, the survey estimates for
37+
May 1st were updated on September 3rd based on new data, giving a ``lag`` of 125 days.
38+
See the `Delphi Epidata API <https://cmu-delphi.github.io/delphi-epidata/api/README.html#epidata-api-other-diseases>`_ documentation for details on all fields of the returned data frame.
39+
40+
The API documentation lists each available signal and provides technical details
41+
on how it is estimated and how its standard error is calculated. In this case,
42+
for example, the `symptom surveys documentation page
43+
<https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/fb-survey.html>`_
44+
explains the definition of "COVID-like illness", links to the exact survey text,
45+
and describes the mathematical derivation of the estimates.
46+
47+
Using the ``geo_values`` argument, we can request data for a specific geography,
48+
such as the state of Pennsylvania for the month of September 2021:
49+
50+
>>> pa_data = epidata[("fb-survey", "smoothed_cli")].call(
51+
... 'state', "pa", EpiRange(20210901, 20210930)
52+
... ).df()
53+
>>> pa_data.head()
54+
source signal geo_type geo_value time_type time_value issue lag value stderr sample_size direction missing_value missing_stderr missing_sample_size
55+
0 fb-survey smoothed_cli state pa day 2021-09-01 2021-09-06 5 0.928210 0.088187 9390 NaN 0 0 0
56+
1 fb-survey smoothed_cli state pa day 2021-09-02 2021-09-07 5 0.894603 0.087308 9275 NaN 0 0 0
57+
2 fb-survey smoothed_cli state pa day 2021-09-03 2021-09-08 5 0.922847 0.088324 9179 NaN 0 0 0
58+
3 fb-survey smoothed_cli state pa day 2021-09-04 2021-09-09 5 0.984799 0.092566 9069 NaN 0 0 0
59+
4 fb-survey smoothed_cli state pa day 2021-09-05 2021-09-10 5 1.010306 0.093357 9016 NaN 0 0 0
60+
61+
We can request multiple states by providing a list, such as ``["pa", "ny",
62+
"mo"]``.

0 commit comments

Comments
 (0)