Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix subclass metadata preservation in groupby column selection #56761

Merged

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Jan 7, 2024

This is a small regression that was introduced with #51090 (in pandas 2.0): before that PR, the column subselection in the groupby code was done with a standard __getitem__ call, while the PR introduced an optimized helper _getitem_nocopy to avoid the copy that a standard __getitem__ does. However, that new helper forgot to add a __finalize__ call after _constructor from a manager.

The reason we noticed this in geopandas (geopandas/geopandas#3130) was to update our tests for the apply deprecation to include group columns (for which one alternative is to specifically select the non-group columns, but so that didn't work with recent pandas versions)

@jorisvandenbossche jorisvandenbossche added Groupby Regression Functionality that used to work in a prior pandas version Subclassing Subclassing pandas objects labels Jan 7, 2024
@jorisvandenbossche jorisvandenbossche added this to the 2.2 milestone Jan 7, 2024
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rhshadrach rhshadrach added the Bug label Jan 7, 2024
@phofl phofl merged commit 99db9af into pandas-dev:main Jan 7, 2024
54 checks passed
@phofl
Copy link
Member

phofl commented Jan 7, 2024

thx @jorisvandenbossche

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 7, 2024
phofl pushed a commit that referenced this pull request Jan 7, 2024
…vation in groupby column selection) (#56770)

Backport PR #56761: BUG: fix subclass metadata preservation in groupby column selection

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche deleted the groupby-gotitem-nocopy-finalize branch January 8, 2024 14:42
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Groupby Regression Functionality that used to work in a prior pandas version Subclassing Subclassing pandas objects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants