Skip to content

_knn_fill repeats the raw-corrwith pattern fixed in #464 and crashes on py3.9 #470

Open

Description

@kevincostner17

Severity: S2 (crash on a supported input, py3.9 lane) — sibling of #464

#464 fixed the raw-corrwith pattern in engine/model_select.py. The same pattern survives at src/freshdata/engine/missing.py:637 (_knn_fill), which is reachable when len(df) < 30.

Root cause is the one #464 turned up: on pandas 1.5, Series.corr receives the raw values, so a nullable Int64 column holding pd.NA arrives as an object array, and numpy 1.26's average() builds its scale factor as a bare Python float, so scl.shape raises:

AttributeError: 'float' object has no attribute 'shape'

fd.clean's gates make this hard to reach through the public API, but a direct call to _knn_fill crashes on py3.9 for any nullable-integer partner column with a missing value.

Fix: the same as #464 — cast to float64 before correlating (what pandas 2.x does internally) and treat ±inf as missing.

Reported by the collaborator working #464; filing here because engine/missing.py is outside that PR's scope.

Activity

  1. WilliamK112 commented on Oct 17, 2026

    @WilliamK112
    Contributor

    This is fixed on current main by #487 (48011ca). _knn_fill now casts both sides to float64 before each corrwith, replaces ±inf with NaN, and tests/test_knn_nullable_correlations.py covers the supported nullable-integer cases, including the Python 3.9/pandas 1.5 failure shape. This issue can be closed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions