Skip to content

REF: simplify PeriodIndex.get_loc #31598

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 15 commits into from
Feb 9, 2020
Merged

Conversation

jbrockmendel
Copy link
Member

This makes PeriodEngine follow patterns in DatetimeEngine, so soon we can have it subclass DatetimeEngine instead of Int64Engine, which will lead to more simplifications.

This also puts us within striking distance of sharing get_loc code

@jbrockmendel jbrockmendel added the Indexing Related to indexing on series/frames, not to indexes themselves label Feb 3, 2020
try:
return self._engine.get_loc(ordinal)
return Index.get_loc(self, key, method, tolerance)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this changes perf? the reason is that we have already created an _int64index, but now we are creating something new?

Copy link
Member Author

Choose a reason for hiding this comment

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

but now we are creating something new?

I don't think we're creating a new object here

Copy link
Contributor

Choose a reason for hiding this comment

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

the engine itself is (maybe) being created again

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 guess on the first all, but on the flip side the _int64index may not have been created yert

@jreback jreback added this to the 1.1 milestone Feb 7, 2020
@jreback jreback added the Period Period data type label Feb 7, 2020
@@ -153,7 +153,6 @@ def test_setitem_ndarray_3d(self, index, obj, idxr, idxr_id):
"floating",
"string",
"datetime64",
"period",
Copy link
Contributor

Choose a reason for hiding this comment

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

what changed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

on the Series.__setitem__ case it now (correctly, i think) raises, as it is trying to instantiate an index with 3D data

Copy link
Member Author

Choose a reason for hiding this comment

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

this test is a mess, is hiding the fact that all of the cases in this block should raise but currently dont (xref #31813)

@jreback
Copy link
Contributor

jreback commented Feb 9, 2020

can you rebase

@jbrockmendel
Copy link
Member Author

rebased+green

@jreback jreback merged commit b42505e into pandas-dev:master Feb 9, 2020
@jbrockmendel jbrockmendel deleted the PeriodEngine branch February 10, 2020 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants