Skip to content

Commit 1328595

Browse files
authored
Merge pull request #529 from cmu-delphi/fix-nchs-timestamp
Fix nchs timestamp
2 parents 6bbc132 + 070117a commit 1328595

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

nchs_mortality/DETAILS.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ consistency how NCHS reports the data, please refer to [Exceptions](#Exceptions)
1010
* `state`: reported using two-letter postal code
1111

1212
## Metrics, Level 1 (`m1`)
13-
* `covid_deaths`: All Deaths with confirmed or presumed COVID-19,
13+
* `deaths_covid_incidence`: All Deaths with confirmed or presumed COVID-19,
1414
coded to ICD–10 code U07.1
15-
* `total_deaths`: Deaths from all causes.
16-
* `percent_of_expected_deaths`: the number of deaths for all causes for this
15+
* `deaths_allcause_incidence`: Deaths from all causes.
16+
* `deaths_percent_of_expected`: the number of deaths for all causes for this
1717
week in 2020 compared to the average number
1818
across the same week in 2017–2019.
19-
* `pneumonia_deaths`: Counts of deaths involving Pneumonia, with or without
19+
* `deaths_pneumonia_notflu_incidence`: Counts of deaths involving Pneumonia, with or without
2020
COVID-19, excluding Influenza deaths(J12.0-J18.9).
21-
* `pneumonia_and_covid_deaths`: Counts of deaths involving COVID-19 and Pneumonia,
21+
* `deaths_covid_and_pneumonia_notflu_incidence`: Counts of deaths involving COVID-19 and Pneumonia,
2222
excluding Influenza (U07.1 and J12.0-J18.9).
23-
* `influenza_deaths`: Counts of deaths involving Influenza, with or without
23+
* `deaths_flu_incidence`: Counts of deaths involving Influenza, with or without
2424
COVID-19 or Pneumonia (J09-J11), includes COVID-19 or
2525
Pneumonia.
26-
* `pneumonia_influenza_or_covid_19_deaths`: Counts of deaths involving Pneumonia,
26+
* `deaths_pneumonia_or_flu_or_covid_incidence`: Counts of deaths involving Pneumonia,
2727
Influenza, or COVID-19, coded to ICD–10
2828
codes U07.1 or J09–J18.9
2929

@@ -32,7 +32,7 @@ Detailed descriptions are provided in the notes under Table 1 [here](https://www
3232
## Metrics, Level 2 (`m2`)
3333
* `num`: number of new deaths on a given week
3434
* `prop`: `num` / population * 100,000
35-
* _**No** `m2` for signal `percent_of_expected_deaths`._
35+
* _**No** `m2` for signal `deaths_percent_of_expected`_.
3636

3737
## Exceptions
3838

@@ -49,10 +49,7 @@ but we don't consider NYC separately. The death counts for NYC would be included
4949
### Report Using Epiweeks
5050

5151
We report the NCHS Mortality data in a weekly format (`weekly_YYYYWW`, where `YYYYWW`
52-
refers to an epiweek). However, NCHS reports their weekly data from Saturday to
53-
Saturday. We assume there is a one day shift. For example, they report a death counts
54-
for Alaska in a week starting from date D, we will report the timestamp of this report
55-
as the corresponding epiweek of date(D + 1).
52+
refers to an epiweek). As defined by CDC, [epiweeks](https://wwwn.cdc.gov/nndss/document/MMWR_Week_overview.pdf) are seven days from Sunday to Saturday. We use Python package [epiweeks](https://pypi.org/project/epiweeks/) to convert the week-ending dates in the raw dataset into epiweek format.
5653

5754
### Data Versioning
5855
Data versions are tracked on both a daily and weekly level.

nchs_mortality/delphi_nchs_mortality/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def export_csv(df, geo_name, sensor, export_dir, start_date):
2626

2727
for date in df["timestamp"].unique():
2828
t = Week.fromdate(pd.to_datetime(str(date)))
29-
date_short = "weekly_" + str(t.year) + str(t.week + 1).zfill(2)
29+
date_short = "weekly_" + str(t.year) + str(t.week).zfill(2)
3030
export_fn = f"{date_short}_{geo_name}_{sensor}.csv"
3131
result_df = df[df["timestamp"] == date][["geo_id", "val", "se", "sample_size"]]
3232
result_df.to_csv(f"{export_dir}/{export_fn}",

nchs_mortality/tests/test_export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_export(self):
2929
)
3030

3131
# check data for 2020-06-02
32-
expected_name = f"weekly_202024_state_region_thing.csv"
32+
expected_name = f"weekly_202023_state_region_thing.csv"
3333
assert exists(join("./receiving", expected_name))
3434

3535
output_data = pd.read_csv(join("./receiving", expected_name))
@@ -40,7 +40,7 @@ def test_export(self):
4040
assert (output_data.sample_size.values == [100, 500, 80]).all()
4141

4242
# check data for 2020-06-03
43-
expected_name = f"weekly_202025_state_region_thing.csv"
43+
expected_name = f"weekly_202024_state_region_thing.csv"
4444
assert exists(join("./receiving", expected_name))
4545

4646
output_data = pd.read_csv(join("./receiving", expected_name))

0 commit comments

Comments
 (0)