-
Notifications
You must be signed in to change notification settings - Fork 3
A new ADRIO for daily influenza data at the state level. #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
JavadocMD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments for changes. Also (if you haven't already) make sure to test that this ADRIO can successfully pull the entire dataset. We want to uncover any surprise data parsing issues.
epymorph/adrio/cdc.py
Outdated
| self, | ||
| *, | ||
| fix_missing: FillLikeInt = False, | ||
| column: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are only two valid values, this should be annotated more narrowly than string. i.e., column: Literal["admissions", "hospitalizations"]
epymorph/adrio/cdc.py
Outdated
| self._fix_missing = Fill.of_int64(fix_missing) | ||
| except ValueError: | ||
| raise ValueError("Invalid value for `fix_missing`") | ||
| if not ((column == "admissions") or (column == "hospitalizations")): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When checking that a variable (especially a string) is in the set of valid values, prefer: column not in ("admissions", "hospitalizations"). It's not much shorter when there are only two valid values, but still there's less room for error (like someone does a copy-paste and changes column to another variable only the first clause).
| order_by=( | ||
| q.Ascending("date"), | ||
| q.Ascending("state"), | ||
| q.Ascending(":id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an FYI: including a sort by row ID is important because with SODA APIs, assembling complete results can require multiple requests (pagination; there's a limit to how many rows can be returned in one request). Thus we need to guarantee that the answer to "what's on page X?" is consistent between requests. Having an unambiguous sort order does that. It's possible date/state are sufficient for this dataset, but including ID makes it very certain and doesn't cost much.
This ADRIO is designed to draw from two columns in the dataset COVID-19 Reported Patient Impact and Hospital Capacity by State Timeseries (RAW) at https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh/about_data
The dataset does not appear to have any missing values, but I retained the missing value checks just in case. Example setup of the ADRIO would look like
cdcadrio_H = cdc.InfluenzaStateHospitalizationDaily( fix_missing=0, column = 'hospitalizations' ).with_context( time_frame=TimeFrame.of("2022-09-15", 7 * 26 + 1), scope=StateScope.in_states(["AZ","NV"], year=2019), )where column can be the string hospitalizations or admissions.