Repository navigation
Fix Series.map(Series) producing wrong results for non-co-aligned inputs - #12432
Merged
Merged
Conversation
The MapAlign fix (repartition mapper to 1 partition + broadcast) handles base_npart != map_npart correctly. 12 more tests pass.
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 25 files + 1 25 suites +1 6h 55m 9s ⏱️ + 5m 5s Results for commit 766ec3a. ± Comparison against base commit 55e016a. ♻️ This comment has been updated with latest results. |
- black reformatted _expr.py (line-length) and test_map.py (conditionals) - xfail test_series_map_dtype_unmapped[Index-values1-bool]: when all keys in a partition are unmapped, Index.map returns float64 (numpy NaN), but the overall result is object (mixed NaN + True). Per-partition dtype consistency check fails — this is a known pandas/dask interaction edge case, not a bug in our fix.
Collaborator
This is really not great for a user that abuses |
crusaderky
approved these changes
Jun 1, 2026
Collaborator
|
Thank you! |
1 task
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.
Summary
Fixes #12426.
Series.map(dask_series)produced NaN values and wrongdtypes when base and mapper had different partitioning.
Root cause: two bugs in the
MapAlign/Mapexpression classes:MapAlign._parametershad a vestigialopfield that shiftedoperand positions when lowering to
Map—na_actionandmetalanded in wrong slots.
MapAligninheritedMaybeAlignPartitions._lower()whichindex-aligns operands. But
Series.map(Series)uses the mapperas a lookup table — every partition needs the full mapper, not
an index-aligned slice.
Fix:
MapAlign._lower()now repartitions the mapper to 1 partitionand passes it to
Mapdirectly, bypassing index alignment.Map._broadcast_dep()broadcasts the single-partition mapper to allframe partitions.
Test plan
test_series_map_dtype_all_mapped,test_series_map_dtype_unmapped,test_series_map_dtype_null_base— all 22+22 variants now pass
Indexfailures unrelatedto this fix (nullable base dtype NA in divisions; float32+object/str
dtype mismatch)
test_series_map_co_aligned_lookup(xfail) documentingthe separate co-aligned path bug
test_map.py: 98 passed, 37 xfailed, 0 failedtest_dataframe.py: 602 passed, 0 failed (regression check)