Skip to content

fix(waterdata): keep the parent statistic in statistics results - #465

Open
bhaskargurram-ai wants to merge 1 commit into
DOI-USGS:mainfrom
bhaskargurram-ai:fix/stats-parent-statistic
Open

bhaskargurram-ai wants to merge 1 commit into
DOI-USGS:mainfrom
bhaskargurram-ai:fix/stats-parent-statistic

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown
Contributor

Fixes #464

get_stats_por() and get_stats_date_range() dropped the parent_statistic_id and parent_statistic_name fields that the Statistics API sends with each series. When a parameter has several daily series at one location (e.g. daily max, min and mean discharge at USGS-08049300), the result had three rows per day with nothing but parent_time_series_id to tell them apart.

_handle_nesting now carries both fields through json_normalize's meta, next to parent_time_series_id, as the R package does. No other column changes.

Tests: test_get_stats_por checks the two columns against the recorded fixture, and a new test_handle_nesting_keeps_parent_statistic checks that three series of one parameter (max, min, mean) come back labelled. Both fail on main and pass with the change. NEWS.md has an entry.

_handle_nesting copied only parameter_code, unit_of_measure and
parent_time_series_id from each data entry of a statistics feature, and
dropped parent_statistic_id and parent_statistic_name. A parameter can
have several daily series at one location (daily max, min and mean
discharge at USGS-08049300, for example), each with its own normals and
intervals, so get_stats_por and get_stats_date_range returned three
medians for 07-01 with nothing but an opaque time series id to tell
which daily statistic each one summarizes.

Carry both fields through json_normalize's meta, as the R package does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_stats_por / get_stats_date_range drop parent_statistic_id, so rows from the daily max, min and mean series can't be told apart

1 participant