Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working) - #280
Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working)#280goosfrabba 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:
|
|
Heads up on the red CI: the macOS failures are environment rot in the old-pandas matrix, not related to this patch — pandas 1.x wheels hitting the numpy 2.x ABI break ( |
|
Some test evidence in support of this, from running the suite on pandas 3.0.3 / Python 3.14.6. Worth flagging that on pandas 3.0 this is no longer a deprecation — So The other 8 failures are unrelated (grouping columns are no longer passed to
One caveat on CI: the workflow matrix targets |
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.