Skip to content

ENH: Implement PeriodIndex.intersection without object-dtype cast #30666

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

Merged
merged 3 commits into from
Jan 4, 2020

Conversation

jbrockmendel
Copy link
Member

PeriodIndex._simple_new is not as simple as it should be. In order to get it to have the appropriate signature we need to implement some of the set methods correctly. This is the first of those.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

LGTM. How does the ASV for period.Indexing.time_intersection look?

@jbrockmendel
Copy link
Member Author

How does the ASV for period.Indexing.time_intersection look?

For the length=1000 index in the benchmark we take a hit of about 37%. When I change the benchmark to be length=10**5 it is no change.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. some comments for followon.

@@ -799,6 +803,30 @@ def _wrap_setop_result(self, other, result):
result.name = name
return result

def intersection(self, other, sort=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

type at some point

self._assert_can_do_setop(other)
res_name = get_op_result_name(self, other)
other = ensure_index(other)

Copy link
Contributor

Choose a reason for hiding this comment

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

can this code be shared with superclasses?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think so, its going to be a few steps before we get there

@jreback jreback added Index Related to the Index class or subclasses Period Period data type Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jan 4, 2020
@jreback jreback added this to the 1.0 milestone Jan 4, 2020
@jreback
Copy link
Contributor

jreback commented Jan 4, 2020

How does the ASV for period.Indexing.time_intersection look?

For the length=1000 index in the benchmark we take a hit of about 37%. When I change the benchmark to be length=10**5 it is no change.

interesting, i though this would be faster. ok

@jreback jreback merged commit 8d5cd1c into pandas-dev:master Jan 4, 2020
@jbrockmendel jbrockmendel deleted the ref-pi-sets branch January 4, 2020 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Period Period data type Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants