Repository navigation
Fix KeyError: 0 on pandas 3 by using .iloc for positional access - #45
Merged
Merged
Conversation
Fix KeyError: 0 on pandas 3.x by using .iloc[0] for positional access
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
==========================================
- Coverage 94.97% 94.36% -0.62%
==========================================
Files 12 12
Lines 1235 1243 +8
==========================================
Hits 1173 1173
- Misses 62 70 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Fixes
KeyError: 0when running with pandas 3.x.Cause
Series[0]on a string-indexed Series (e.g.model.tvalues, indexed by variable name) used to fall back to positional access. That fallback was deprecated in pandas 2.1 and removed in 3.0, sopartial_r2andextract_from_modelnow raiseKeyError: 0.Changes
.iloc[0]for positional access insensitivity_statistics.pyandsensitivity_plots.py.Testing
Environment: macOS, Python 3.14.0, pandas 3.0.6
(run with
pytest --continue-on-collection-errorsfor "before", sincetests/test_ovb_plots.pyotherwise aborts collection)KeyError: 0; a fewSystemExit: [...] must be numeric). Coverage 67%.