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

Preserve name of the column while initializing a DataFrame #14110

Merged
merged 7 commits into from
Sep 27, 2023

Conversation

galipremsagar
Copy link
Contributor

Description

Fixes: #14088

This PR preserves names of column object while constructing a DataFrame through various constructor flows.

Checklist

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

@galipremsagar galipremsagar added bug Something isn't working 3 - Ready for Review Ready for review by team Python Affects Python cuDF API. 4 - Needs cuDF (Python) Reviewer non-breaking Non-breaking change labels Sep 13, 2023
@galipremsagar galipremsagar requested a review from a team as a code owner September 13, 2023 21:06
@galipremsagar galipremsagar self-assigned this Sep 13, 2023
@@ -712,6 +715,11 @@ def __init__(

self._data = new_df._data
self._index = new_df._index
self._data._level_names = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need some kind of helper to normalize this? I see this repeated a lot of times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

While the helper does reduce the amount of code somewhat, I think it reduces the overall comprehensibility sadly :( I also find it a bit out-of-place for this helper to live in column_accessor.py.

I think either we should:

  • Rethink the helper's name and API
  • Go back to not having a helper (more explicit but also more code)

@bdice would you concur?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was on the fence about whether a helper was appropriate here. I feel pretty neutral about the implementation in 88ccc48 -- I would accept the PR with or without the helper, since the DRY benefit and benefit of explicit logic are about even to me. @shwina If you think we should revert that change, I'm fine with that. I don't have any clear improvements to propose for names or APIs of the helper.

@galipremsagar galipremsagar added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team 4 - Needs cuDF (Python) Reviewer labels Sep 27, 2023
@galipremsagar
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit b789d4c into rapidsai:branch-23.10 Sep 27, 2023
57 checks passed
@galipremsagar
Copy link
Contributor Author

Thanks @shwina & @bdice !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG] Columns name not being preserved in DataFrame constructor
3 participants