-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
PERF: RangeIndex.is_monotonic_inc/dec #13749
Conversation
Current coverage is 84.57% (diff: 100%)
|
self.assertTrue(index.is_monotonic) | ||
self.assertTrue(index.is_monotonic_increasing) | ||
self.assertTrue(index.is_monotonic_decreasing) | ||
|
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.
Maybe add a test for the empty case as well?
In [23]: pd.RangeIndex().is_monotonic_increasing
Out[23]: True
In [24]: pd.RangeIndex().is_monotonic_decreasing
Out[24]: True
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.
Although this should maybe rather raise an error (@jreback)
Other index types to raise without arguments, and range()
does as well.
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.
@jorisvandenbossche empty case is coverd by (1, 1)
.
pd.RangeIndex(1, 1).values
# array([], dtype=int64)
Let me issue a separate PR to prohibit empty construction.
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.
Ah yes, assumed that RangeIndex()
does not has a step yet, but that is of course wrong :-)
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.
yeah I don't think RangeIndex()
should be permitted, though I seem to remember needing it for unpickling or somesuch.......
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.
let's make a new issue about the empty RangeIndex()
git diff upstream/master | flake8 --diff
as the same as
is_unique
, it should be monotonic by definition