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

Avoid redefining Frame._get_columns_by_label in subclasses #15912

Merged

Conversation

mroeschke
Copy link
Contributor

Description

Frame._get_columns_by_label was redefined in Series and DataFrame to handle some special edge cases in DataFrame.__getitem__ and empty Series

By making _from_data_like_self more consistent in preserving external properties and moving special casing, we can only define Frame._get_columns_by_label once

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 4, 2024
@mroeschke mroeschke requested a review from a team as a code owner June 4, 2024 02:57
Copy link
Member

@charlesbluca charlesbluca left a comment

Choose a reason for hiding this comment

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

Thanks @mroeschke! One question but overall LGTM

Comment on lines +1445 to +1448
if by is None:
to_sort = self._columns
else:
to_sort = self._get_columns_by_label(list(by))._columns
Copy link
Member

Choose a reason for hiding this comment

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

Outside of dropping of downcast, is there any reason for the restructure here? Are there cases where we would expect the unpacking here not to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was mostly a micro-optimization to avoid the unnecessary unpacking of the if by is None case

@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 9225633 into rapidsai:branch-24.08 Jun 14, 2024
76 checks passed
@mroeschke mroeschke deleted the ref/_get_columns_by_labels branch June 14, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants