fix(ogc): stable float64 numeric columns, warn on unparseable values - #429
Merged
thodson-usgs merged 1 commit intoOct 1, 2026
Merged
Conversation
thodson-usgs
force-pushed
the
fix/428-stable-numeric-dtypes
branch
2 times, most recently
from
October 1, 2026 14:39
f7a871e to
00b8ae9
Compare
…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
force-pushed
the
fix/428-stable-numeric-dtypes
branch
from
October 1, 2026 15:15
d82360f to
f889e35
Compare
thodson-usgs
marked this pull request as ready for review
October 1, 2026 15:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #428 (items 1 and 2).
Summary
ogc.shaping._type_colscasts every dialect numeric column tofloat64.pd.to_numericinferredint64when all values in a response were whole, sovalue,altitude,drainage_area, etc. changed dtype between calls. Applies towaterdataOGC getters andngwmn.NaN/NaT(one bad value doesn't fail a large download), but aUserWarningnow names the column and count and points toconvert_type=False. Nulls and empty strings are treated as missing and don't warn.Not included: the optional
dtype_backendpass-through (item 3). It adds a parameter to every getter's public signature for something callers can do with onedf.convert_dtypes(dtype_backend=...)call; better as a separate discussion.Contracts / ADRs
The change lives in the
finalizehook, where ADR 0008 puts result shaping, so resumed chunked calls get the same dtypes. No ADR, import-linter contract, or public signature changes.Tested
get_dailywith all-whole values returnsfloat64;_type_colsreturnsfloat64for whole/empty/all-null columns, warns on unparseable numbers and datetimes, stays silent on null/empty. They fail onmain(5 of 7).