Skip to content

fix(ogc): stable float64 numeric columns, warn on unparseable values - #429

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/428-stable-numeric-dtypes
Oct 1, 2026
Merged

thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/428-stable-numeric-dtypes

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Closes #428 (items 1 and 2).

Summary

  • ogc.shaping._type_cols casts every dialect numeric column to float64. pd.to_numeric inferred int64 when all values in a response were whole, so value, altitude, drainage_area, etc. changed dtype between calls. Applies to waterdata OGC getters and ngwmn.
  • Values that fail to parse still become NaN/NaT (one bad value doesn't fail a large download), but a UserWarning now names the column and count and points to convert_type=False. Nulls and empty strings are treated as missing and don't warn.
  • NEWS entry with the two behavior changes.

Not included: the optional dtype_backend pass-through (item 3). It adds a parameter to every getter's public signature for something callers can do with one df.convert_dtypes(dtype_backend=...) call; better as a separate discussion.

Contracts / ADRs

The change lives in the finalize hook, where ADR 0008 puts result shaping, so resumed chunked calls get the same dtypes. No ADR, import-linter contract, or public signature changes.

Tested

  • New tests: get_daily with all-whole values returns float64; _type_cols returns float64 for whole/empty/all-null columns, warns on unparseable numbers and datetimes, stays silent on null/empty. They fail on main (5 of 7).
  • Full offline suite: 1184 passed; coverage 98.94%.
  • ruff, mypy (strict), lint-imports, xenon, complexipy all pass.

@thodson-usgs
thodson-usgs force-pushed the fix/428-stable-numeric-dtypes branch 2 times, most recently from f7a871e to 00b8ae9 Compare October 1, 2026 14:39
…DOI-USGS#428)

pd.to_numeric infers int64 when every value in a response is whole, so a
waterdata/ngwmn measurement column changed dtype from call to call.
_type_cols now casts numeric columns to float64.

Values that fail to parse still become NaN/NaT, so one bad value does not
fail a large download, but a UserWarning now names the column and the
count ("1 value" / "N values") and points to convert_type=False. Null and
empty-string values are missing rather than parse failures and are not
counted.

get_monitoring_locations' construction_date holds partial dates (1925,
194805, 19100000) that were already being dropped without notice, so the
warning will appear there; NEWS says so. format="ISO8601" was considered
and not adopted: a live check found no mixed forms in any time column,
and it would fill year-only construction dates out to January 1.

Not included: the dtype_backend pass-through suggested in the issue.

Co-authored-by: Anthony Aufdenkampe <5166036+aufdenkampe@users.noreply.github.com>
@thodson-usgs
thodson-usgs force-pushed the fix/428-stable-numeric-dtypes branch from d82360f to f889e35 Compare October 1, 2026 15:15
@thodson-usgs
thodson-usgs marked this pull request as ready for review October 1, 2026 15:24
@thodson-usgs
thodson-usgs merged commit ff905de into DOI-USGS:main Oct 1, 2026
11 checks passed
@thodson-usgs
thodson-usgs deleted the fix/428-stable-numeric-dtypes branch October 1, 2026 15:27
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.

waterdata: value dtype depends on the data, and unparseable values silently become NaN

1 participant