Skip to content

PeriodIndex.is_monotonic only for monotonic increasing #21335

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

Closed
jbrockmendel opened this issue Jun 6, 2018 · 3 comments · Fixed by #45422
Closed

PeriodIndex.is_monotonic only for monotonic increasing #21335

jbrockmendel opened this issue Jun 6, 2018 · 3 comments · Fixed by #45422
Labels
Bug Index Related to the Index class or subclasses Period Period data type
Milestone

Comments

@jbrockmendel
Copy link
Member

dti = pd.date_range('2016-01-01', periods=3)
pi = dti.to_period('D')

>>> pi.is_monotonic
True
>>> pi[::-1].is_monotonic
False
@gfyoung gfyoung added Indexing Related to indexing on series/frames, not to indexes themselves Period Period data type Bug labels Jun 6, 2018
@gfyoung
Copy link
Member

gfyoung commented Jun 6, 2018

Oops. Patch is most welcome!

@uds5501
Copy link
Contributor

uds5501 commented Jun 6, 2018

@jbrockmendel I guess you would like to check out pandas 0.23.0 documentation where it is stated that series.is_monotonic returns boolean if values in the object are monotonic_increasing.

If you want to check the monotnicity of the series, how about using this:
>>> pi[::-1].is_monotonic_increasing or pi[::-1].is_monotonic_increasing

@gfyoung
Copy link
Member

gfyoung commented Jun 6, 2018

@uds5501 : That's a good point. I forgot about that myself 😂

That being said, it does seem a little counter-intuitive, especially since we have both is_monotonic_increasing and is_monotonic_decreasing.

@gfyoung gfyoung removed the Bug label Jun 6, 2018
@toobaz toobaz added Index Related to the Index class or subclasses and removed Indexing Related to indexing on series/frames, not to indexes themselves labels Jun 29, 2019
@mroeschke mroeschke added the Bug label May 5, 2020
@jreback jreback added this to the 1.5 milestone Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Index Related to the Index class or subclasses Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants