Skip to content

Support ffill and bfill for non-numeric NumPy dtypes (datetime64, timedelta64, bool, str, object) - #11945

Open
lance-lii wants to merge 1 commit into
pydata:mainfrom
lance-lii:lance-lii/ffill-non-float-dtypes
Open

lance-lii wants to merge 1 commit into
pydata:mainfrom
lance-lii:lance-lii/ffill-non-float-dtypes

Conversation

@lance-lii

Copy link
Copy Markdown

Description

Adds a plain NumPy ffill/bfill path (_push_numpy) for non-numeric NumPy dtypes (datetime64, timedelta64, bool, string, and object) so they work without numbagg or bottleneck, and updates the dask push path (xarray/compat/dask_array_ops.py) to use isnull and preserve original values for gaps longer than limit.

Context:

  • Under numbagg (the default when installed), ffill/bfill fails on datetime64, timedelta64, object, str, and bool dtypes.
  • Under bottleneck, datetime64 forward-fill rounds through float64 and loses nanosecond precision.
  • With dask, the cross-chunk blelloch scan path assumed float data (np.isnan / da.isnan / da.where(..., np.nan)), which failed on non-float dtypes and converted chunked integer arrays with limit larger than a chunk to float64.

Numeric NumPy dtypes (float, int, complex) and pandas extension dtypes keep their existing numbagg/bottleneck behavior unchanged.

Related to #4587 and #8981.

Checklist

  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      Tools: Claude Code (Claude Opus 5.5) used to help draft the implementation, dask adjustments, and regression tests; I reviewed the diff and verified the test suite locally.

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added topic-dask topic-arrays related to flexible array support labels Nov 26, 2026

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

topic-arrays related to flexible array support topic-dask

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant