-
Notifications
You must be signed in to change notification settings - Fork 902
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
Conversation
@@ -712,6 +715,11 @@ def __init__( | |||
|
|||
self._data = new_df._data | |||
self._index = new_df._index | |||
self._data._level_names = ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
88ccc48
to
b4d963e
Compare
/merge |
Description
Fixes: #14088
This PR preserves
names
ofcolumn
object while constructing aDataFrame
through various constructor flows.Checklist