fix: pandas compat in impute.py, update CI runners and Python versions#159
Merged
Conversation
- Fix chained assignment in impute.py _fit_encode/_encode to use .loc indexing instead of X[col].loc[] which breaks pandas Copy-on-Write - Convert string columns to object dtype before processing to avoid StringDtype incompatibility with newer pandas - Replace deprecated macos-13 runner with macos-14 - Promote Python 3.13 from experimental to stable in CI matrix - Add Python 3.14 as experimental across all platforms Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace `F(len)(A)[0]` with `F(len)(A).iloc[0]` to fix KeyError on pandas 3.x where string-indexed Series no longer accept integer keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In pandas 3.x, Index.values returns StringArray instead of numpy array. Using .tolist() ensures str() gives the expected list format `['A']` instead of `<StringArray>` in the duplicate keys error message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DataFrame.applymap was removed in pandas 3.0. Use DataFrame.map instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
toad/impute.pychained assignment (X[col].loc[~mask]) that breaks with pandas Copy-on-Write (pandas >= 2.x), replacing with proper.locindexingobjectdtype before processing to avoidStringDtypeincompatibility with newer pandasmacos-13runner withmacos-14in CI workflowRoot Cause
The
test_impute_with_strtest failed on Python 3.11/3.12/3.13 because newer pandas enforces Copy-on-Write and stricter string dtype handling. The chained assignment patternX[col].loc[~mask[col]] = valueis no longer supported.Test plan
test_impute_with_strspecifically passes on Python 3.11+macos-14runner🤖 Generated with Claude Code