ueshin opened a new pull request, #54276:
URL: https://github.com/apache/spark/pull/54276
### What changes were proposed in this pull request?
Make `groupby(as_index=False)` include a grouping that is not in the
DataFrame with pandas 3.
### Why are the changes needed?
The behavior of `groupby(..., as_index=False)` has changed in pandas 3.
It includes a grouping that is not in the DataFrame.
For example:
```py
>>> pdf1 = pd.DataFrame({"c": [4, 2, 7, 3, None, 1, 1, 1, 2, 2], "d":
list("abcdefghti")})
>>> pdf2 = pd.DataFrame({"a": [1, 2, 6, 4, 4, 6, 4, 3, 7], "b": [4, 2, 7, 3,
3, 1, 1, 1, 2]})
```
- pandas 2
```py
>>> pdf1.groupby(pdf2.a, as_index=False)["c"].sum()
c
0 4.0
1 2.0
2 1.0
3 4.0
4 8.0
5 2.0
```
- pandas 3
```py
>>> pdf1.groupby(pdf2.a, as_index=False)["c"].sum()
a c
0 1.0 4.0
1 2.0 2.0
2 3.0 1.0
3 4.0 4.0
4 6.0 8.0
5 7.0 2.0
```
### 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?
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]