-
Notifications
You must be signed in to change notification settings - Fork 930
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
Transfer correct dtype to exploded column #11687
Merged
rapids-bot
merged 8 commits into
rapidsai:branch-22.10
from
wence-:wence/fix/explode-nested-dtype-copy
Sep 19, 2022
+152
−47
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a92f61
Transfer correct dtype to exploded column
wence- a15731d
No hypothesis this time
wence- 08a2aa7
Factor out index metadata transfer into separate method
wence- b86fdaf
Sui generis copy of type metadata in _explode
wence- c1bb83e
Back out by-hand type construction in _explode
wence- 9d72177
More new keyword arguments
wence- 3e409e2
No need for enumerate
wence- 2e06a63
Replace incomprehensible Haskell with imperative code
wence- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't this copying of type metadata happen after
self._from_columns_like_self
call? i.e., on the result ofself._from_columns_like_self
?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.
No, but you would be forgiven for thinking so. This is exploiting (although I didn't notice that this was what was going on until responding here) fallthrough behaviour in
_from_columns_like_self
in the case where the dtype shape of the target and source frames does not match._from_columns_like_self
attempts to copy type metadata fromself
ontoother
. The interesting part for this argument is how the columns are collectedOK, so for the non-exploded columns this does the right thing (it's a no-op because the dtypes match). For the exploded column the dtypes do not match. The
self
version isListDtype(element_type)
theother
version is (structurally at least) iselement_type
. So eventually we end up callingstruct_column._with_type_metadata(list_dtype)
:We don't tick one of the specific cases, so just return ourselves, and come back up through the call tree.
Given the use case, I'm not sure why we don't just update the dtype of the exploded column and then call
_from_columns
.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 think we could do either one of these:
cols_to_ignore_copy_metadata
to_from_columns_like_self
which will ignore copying metadata of the columns while constructing dataframe and will just copy the dtypes of columns that are not incols_to_ignore_copy_metadata
.self._from_columns_like_self
but then hand construct the frame by carefully taking into account which dtypes to be copied to new columns. The reason being, we are constructing a dataframe that is a mix of self-like columns and non-self-like columns.I feel approach 2 might be the desired solution as this may be a one-off. But as list & struct operations expand more we might need to have some kind of capability as mentioned in approach 1.
cc: @shwina if you have any insights on this.
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've gone for option (2) for now.