Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working)#280
Open
goosfrabba wants to merge 1 commit into
Open
Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working)#280goosfrabba wants to merge 1 commit into
goosfrabba wants to merge 1 commit into
Conversation
…pandas < 2.1 pandas >= 2.1 deprecates DataFrame.applymap in favour of DataFrame.map, so parallel_applymap raises a FutureWarning (nalepae#258). ApplyMap.work now uses DataFrame.map when the installed pandas provides it and falls back to applymap otherwise, fixing the deprecation without dropping pandas < 2.1 or bumping the minimum Python version (the concern raised on nalepae#259). The reference computation in test_dataframe_applymap uses the same capability check so it stays warning-free.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #280 +/- ##
===========================================
- Coverage 91.28% 79.55% -11.73%
===========================================
Files 12 12
Lines 585 587 +2
===========================================
- Hits 534 467 -67
- Misses 51 120 +69 ☔ 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.
Fixes #258.
On pandas >= 2.1,
DataFrame.applymapis deprecated in favour ofDataFrame.map, soparallel_applymapcurrently raisesFutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead(frompandarallel/data_types/dataframe.py).This makes the elementwise apply version-aware: it uses
DataFrame.mapwhen the installed pandas provides it (>= 2.1) and falls back toDataFrame.applymapotherwise. That resolves the deprecation without dropping support for pandas < 2.1 and without raising the minimum Python version, addressing the concern raised on #259 (a hardapplymap->mapswap).pandarallel/data_types/dataframe.py:ApplyMap.workpicksmap/applymapby capability.tests/test_pandarallel.py: the reference intest_dataframe_applymapuses the same capability check so it stays warning-free across pandas versions.A sensible follow-up is extending the CI matrix to pandas 2.1/2.2 and Python 3.11-3.13 so this class of regression is caught automatically.