Skip to content

Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working)#280

Open
goosfrabba wants to merge 1 commit into
nalepae:masterfrom
goosfrabba:fix-applymap-deprecation-pandas-2.1
Open

Fix DataFrame.applymap deprecation on pandas >= 2.1 (keeps pandas < 2.1 working)#280
goosfrabba wants to merge 1 commit into
nalepae:masterfrom
goosfrabba:fix-applymap-deprecation-pandas-2.1

Conversation

@goosfrabba

Copy link
Copy Markdown

Fixes #258.

On pandas >= 2.1, DataFrame.applymap is deprecated in favour of DataFrame.map, so parallel_applymap currently raises FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead (from pandarallel/data_types/dataframe.py).

This makes the elementwise apply version-aware: it uses DataFrame.map when the installed pandas provides it (>= 2.1) and falls back to DataFrame.applymap otherwise. 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 hard applymap -> map swap).

  • pandarallel/data_types/dataframe.py: ApplyMap.work picks map/applymap by capability.
  • tests/test_pandarallel.py: the reference in test_dataframe_applymap uses 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.

…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

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.55%. Comparing base (261a652) to head (f4e59d5).

Files with missing lines Patch % Lines
pandarallel/data_types/dataframe.py 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (261a652) and HEAD (f4e59d5). Click for more details.

HEAD has 58 uploads less than BASE
Flag BASE (261a652) HEAD (f4e59d5)
63 5
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataFrame.applymap has been deprecated.

1 participant