Compatibility layer for pandas3 changing fill_value for sparse from 0 to NaN#1118
Closed
Compatibility layer for pandas3 changing fill_value for sparse from 0 to NaN#1118
Conversation
for more information, see https://pre-commit.ci
…-failure-on-python-312
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1118 +/- ##
==========================================
- Coverage 66.21% 66.21% -0.01%
==========================================
Files 44 44
Lines 7163 7168 +5
Branches 1217 1218 +1
==========================================
+ Hits 4743 4746 +3
- Misses 1943 1944 +1
- Partials 477 478 +1
🚀 New features to boost your workflow:
|
Member
|
hi I have an alternative solution to this. Normally something simpler is enough for this PR but I also wanted to get rid of an unreliable function so I created this PR: #1119 |
Member
Author
|
Closed in favor of #1119 |
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.
pandas 3.0 changed
DataFrame.sparse.from_spmatrixto usefill_value=NaNinstead offill_value=0for float columns (pandas PR #59064). Withfill_value=NaN,groupby().mean()excludes those zeros from the denominator, inflating means and producing wrong results in ligrec.The fix wraps the
from_spmatrixcall inPermutationTestABC.__init__with a small helper that resets anyfill_value=NaNsparse columns back tofill_value=0. It's skipped on pandas <3.