Repository navigation
fix(storage): replace removed DataFrame.applymap in LazyFileStorage - #562
Merged
Merged
Conversation
DataFrame.applymap was removed in pandas 3.0 and requirements.txt does not
pin pandas, so a fresh install resolves to pandas 3.x and any operator that
writes a DataFrame through LazyFileStorage fails with:
AttributeError: 'DataFrame' object has no attribute 'applymap'
DataFrame.map is the replacement and exists since pandas 2.1; keep a fallback
for environments still on an older pandas. FileStorage.write in the same file
already uses data.map, so this brings LazyFileStorage in line with its sibling.
Collaborator
|
LGTM, thanks. PR will be merged after CI check. |
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.
What
LazyFileStorage.writecallsDataFrame.applymap, which was removed in pandas 3.0. Any operator that writes a DataFrame throughLazyFileStoragenow fails with:Why this is live, not a deprecation warning
requirements.txtdoes not constrain pandas, so a fresh install today resolves to 3.x and hits this on the first write. The bundled example pipelines never reach it because they write throughFileStorage, notLazyFileStorage— which is exactly why the failure is invisible until someone uses the lazy path.This is the site #371 missed
#371 ("switch
df.applymap()todf.map") changed one line in this file —FileStorage.write— and leftLazyFileStorage.writeon the removed API. The two classes are siblings with the same shape:mainFileStoragewritedata.map(clean_surrogates)— fixed by #371LazyFileStoragewritedata.applymap(clean_surrogates)— this PRFix
DataFrame.mapis the replacement and has existed since pandas 2.1. Keep a fallback so environments still on an older pandas are unaffected:Evidence
Bidirectional check against
05a7d9e(currentmain), Python 3.13.14 / pandas 3.0.6:The second test does not just assert "no exception": it checks that surrogate cleaning still happens and that the written file round-trips, so the fix cannot silently change behaviour.
grep -rn applymap dataflow/now returns only the fallback branch above.Happy to drop the fallback if you consider pandas < 2.1 out of scope.