Fix/cummax cummin pyarrow float#66283
Open
genrichez wants to merge 2 commits into
Open
Conversation
added 2 commits
July 10, 2026 10:28
… extension arrays When `df.loc[:, bool_mask] = value` is called with a boolean mask that selects no columns on a single-column DataFrame with a nullable extension dtype (Float64, Int64, string, boolean, etc.), the values are incorrectly overwritten. Root cause: In ExtensionBlock._unwrap_setitem_indexer, the condition `is_list_like(indexer[1]) and indexer[1][0] == 0` incorrectly matches boolean arrays because `False == 0` evaluates to True in Python. This causes the column indexer to be discarded and the row indexer (slice(None)) to be used alone, selecting all rows for assignment. Fix: Add an early return in BlockManager.setitem() that detects an all-False boolean column indexer and returns without modification. This mirrors the existing early-return pattern already present in the Copy-on-Write branch (line 571-572). Closes pandas-dev#66255
pyarrow's cumulative_max/min use the smallest positive normal float (~2.2e-308) and largest finite float as default start values. This gives wrong results when the running max is negative or the running min is +inf. Pass start=-inf for cummax and start=+inf for cummin explicitly when the dtype is floating, matching numpy behavior.
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.
BUG: fix cummax/cummin for pyarrow float dtypes
Closes #66257
What's wrong
Series.cummax()on pyarrow float columns returns garbage when the running max is negative. For example:Same idea for
cumminwhen the running min is+inf.Why it happens
pyarrow.compute.cumulative_maxdefaults itsstartparameter to the smallest positive normal float (~2.2e-308 for float64), not-inf. So any negative value loses to that default. Similarlycumulative_mindefaults to the largest finite float, not+inf.The fix
Pass
start=-infforcummaxandstart=+infforcumminwhen the array dtype is floating. This matches numpy behavior exactly. Integer and temporal types are unaffected (pyarrow already uses correct defaults for those).Tests
Added regression tests covering:
+infin cummin