-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF/INT: preserve block type in joining when only having a single block #17954
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5182,7 +5182,15 @@ def concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy): | |
|
||
for placement, join_units in concat_plan: | ||
|
||
if is_uniform_join_units(join_units): | ||
if len(join_units) == 1 and not join_units[0].indexers: | ||
b = join_units[0].block | ||
values = b.values | ||
if copy: # and values.base is not None: | ||
values = values.copy() | ||
elif not copy: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason for this special case? IOW, why can't you handle this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the separate special case because it occurs in different cases (and so how it is here, is more close to the original code), but could add it to the other special case. But, that makes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok I guess. Still like to come back in and re-org this to make as clear as possible during next release. Do appreciate the support for CustomBlocks, though worry we are adding even more technical debt here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah what I would actually do is define a Then all of the concat logic is in a single place and copies are handled there. Pls create an issue for 0.22 for this (you may already have one). |
||
values = values.view() | ||
b = b.make_block_same_class(values, placement=placement) | ||
elif is_uniform_join_units(join_units): | ||
b = join_units[0].block.concat_same_type( | ||
[ju.block for ju in join_units], placement=placement) | ||
else: | ||
|
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.
@jreback I first had this with
and values.base is not None:
but that failed one test inmerge
. But I copied that logic fromconcatenate_join_units
:https://github.com/jorisvandenbossche/pandas/blob/2125ac09726cfc720def79e836398ed04ecae04a/pandas/core/internals.py#L5332
Not sure why there it is needed, but here it fails.