-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: join/merge on subset of MultiIndex #48611
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 2 commits
00034d8
0ab2d01
ad3f42b
c01606d
2b24442
cbf0f76
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 |
---|---|---|
|
@@ -1678,21 +1678,19 @@ def _convert_to_multiindex(index: Index) -> MultiIndex: | |
join_codes = join_index.codes | ||
join_names = join_index.names | ||
|
||
# lindexer and rindexer hold the indexes where the join occurred | ||
# for left and right respectively. If left/right is None then | ||
# the join occurred on all indices of left/right | ||
if lindexer is None: | ||
lindexer = range(left.size) | ||
|
||
if rindexer is None: | ||
rindexer = range(right.size) | ||
|
||
# Iterate through the levels that must be restored | ||
for dropped_level_name in dropped_level_names: | ||
# lindexer and rindexer hold the indexes where the join occurred | ||
# for left and right respectively. If left/right is None then | ||
# the join occurred on all indices of left/right | ||
if dropped_level_name in left.names: | ||
if lindexer is None: | ||
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. Why are you pulling this inside the loop? This is harder to read than before 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. Agreed. We can actually avoid calling take_nd when the indexers are None as that means "take everything". I made another commit which further improves times and should be clearer.
|
||
lindexer = np.arange(left.size) | ||
idx = left | ||
indexer = lindexer | ||
else: | ||
if rindexer is None: | ||
rindexer = np.arange(right.size) | ||
idx = right | ||
indexer = rindexer | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.