Skip to content

fix: nullable integer streaming stats on pandas < 2 - #192

Merged
kevincostner17 merged 1 commit into
mainfrom
fix/nullable-int-pandas15
Sep 14, 2026
Merged

kevincostner17 merged 1 commit into
mainfrom
fix/nullable-int-pandas15

Conversation

@kevincostner17

Copy link
Copy Markdown
Contributor

Summary

test-matrix (3.9), which runs pandas 1.5.3 and numpy 2.0.2, has been failing on main since #187 merged:

FAILED tests/test_nullable_int_median.py::test_seasonal_imputation_global_median_on_nullable_int[Int16]
FAILED tests/test_nullable_int_median.py::test_seasonal_imputation_global_median_on_nullable_int[UInt8]
ValueError: cannot convert to 'float64'-dtype NumPy array with missing values. Specify an appropriate 'na_value' for this dtype.

The new test surfaced an existing pandas < 2 bug, not a problem in the median fix. StreamingState folds each numeric column into its running stats with pd.to_numeric(s).to_numpy(dtype="float64"), which pandas 1.5 refuses for masked Int*/UInt* columns containing NA:

src/freshdata/api.py:782              cleaner.clean_batch(df)
src/freshdata/streaming/_cleaner.py:115  self.state.observe_batch(...)
src/freshdata/streaming/_state.py:231    state.update(df[col])
src/freshdata/streaming/_state.py:110    pd.to_numeric(s, errors="coerce").to_numpy(dtype="float64")

So fd.clean_timeseries / StreamingCleaner crashed on pandas 1.5 for any nullable integer column with gaps.

Changes

Verification

  • Python 3.9 / pandas 1.5.3 / numpy 1.26: pytest tests/test_nullable_int_median.py tests/test_streaming_timeseries.py tests/test_missing.py tests/test_simple.py gives 116 passed. Before this change, the two seasonal cases failed with the error above.
  • Python 3.12 / pandas 2.3.3 / numpy 2.5.3: pytest tests/test_nullable_int_median.py tests/test_streaming_timeseries.py tests/test_streaming_reports.py gives 80 passed.
  • ruff check src/freshdata/streaming: clean. The workflow parses as YAML, and no unpinned uses: remain.

test-matrix (3.9) has failed on main since #187: with pandas 1.5, the
streaming state converted numeric columns via
pd.to_numeric(s).to_numpy(dtype="float64"), which raises "cannot convert to
'float64'-dtype NumPy array with missing values" for nullable (masked)
integer columns with NA. fd.clean_timeseries and StreamingCleaner hit it on
any Int*/UInt* column with gaps.

Pass na_value=np.nan there and in the time-series interpolation helper,
which has the same conversion. Also pin the alert step #188 added to
fetch-fixtures.yml, which #190's SHA sweep predated.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: bbaa530f-44db-445c-9369-d94fdc4bb3e4


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kevincostner17
kevincostner17 merged commit 9ed7993 into main Sep 14, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown

FreshData benchmark report — performance

  • freshdata: ?
  • python: ?
  • platform: ?
fixture n_rows n_cols p50 s p95 s peak MB repair % false-repair % preserve % trust monotonic export %

Authored-code reduction (Metric 6)

kevincostner17 added a commit that referenced this pull request Sep 14, 2026
- perf-regression.yml installs with -c constraints/ci.txt like the other
  gating jobs (left out of #194 to avoid conflicting with #193).
- MissForest convergence converts with to_numpy(dtype="float64",
  na_value=np.nan): the same pandas < 2 masked-array conversion that #192
  fixed in the streaming state. Adds a nullable Int16 MissForest test.
- contributor-roadmap.md no longer advertises #33 and #31, which are
  resolved; it points at the good-first-issue label instead.
@kevincostner17
kevincostner17 deleted the fix/nullable-int-pandas15 branch September 14, 2026 18:58
kevincostner17 added a commit that referenced this pull request Sep 14, 2026
…#216)

#192 fixed a user-facing crash in fd.clean_timeseries / StreamingCleaner on
nullable integer columns with gaps under pandas < 2, and #195 applied the
same NA-safe conversion to MissForest, but neither added a CHANGELOG entry.
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.

1 participant