[SPARK-55296][PS] Support CoW mode with pandas 3#54375
Closed
ueshin wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-55296][PS] Support CoW mode with pandas 3#54375ueshin wants to merge 1 commit intoapache:masterfrom
ueshin wants to merge 1 commit intoapache:masterfrom
Conversation
Member
Author
HyukjinKwon
approved these changes
Feb 19, 2026
Yicong-Huang
approved these changes
Feb 19, 2026
Contributor
|
I didn't realize that this fix could be so clean. Great work! I guess this fix by itself should clear up many test failures. |
Member
Author
|
Thanks! merging to master. |
HyukjinKwon
pushed a commit
that referenced
this pull request
Feb 20, 2026
### What changes were proposed in this pull request? This is a follow-up of #54375. Fixes CoW mode not to break `groupby`. Delays to disconnect the anchor to when actually being updated. ### Why are the changes needed? The CoW mode was supported at #54375, but it disconnected the anchor too early, causing to break `groupby`. ```py >>> import pandas as pd >>> import pyspark.pandas as ps >>> >>> pdf1 = pd.DataFrame({"C": [0.362, 0.227, 1.267, -0.562], "B": [1, 2, 3, 4]}) >>> pdf2 = pd.DataFrame({"A": [1, 1, 2, 2]}) >>> >>> psdf1 = ps.from_pandas(pdf1) >>> psdf2 = ps.from_pandas(pdf2) >>> >>> pdf1.groupby([pdf1.C, pdf2.A]).agg("sum").sort_index() B C A -0.562 2 4 0.227 1 2 0.362 1 1 1.267 2 3 >>> psdf1.groupby([psdf1.C, psdf2.A]).agg("sum").sort_index() C B C A -0.562 2 -0.562 4 0.227 1 0.227 2 0.362 1 0.362 1 1.267 2 1.267 3 ``` ### Does this PR introduce _any_ user-facing change? Yes, it will behave more like pandas 3. ### How was this patch tested? The existing tests should pass. ### Was this patch authored or co-authored using generative AI tooling? Codex (GPT-5.3-Codex) Closes #54392 from ueshin/issues/SPARK-55296/fix_groupby. Authored-by: Takuya Ueshin <ueshin@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
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 changes were proposed in this pull request?
Support CoW (Copy-on-Write) mode with pandas 3.
Why are the changes needed?
Pandas 3 is doing copy-on-write for everything.
For example:
Or for
Series:Does this PR introduce any user-facing change?
Yes, it will behave more like pandas 3.
How was this patch tested?
Updated the related tests to make it clear, but basically the existing tests should pass.
Was this patch authored or co-authored using generative AI tooling?
Codex (GPT-5.3-Codex)