-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: Improve error message on non-sorted input with .truncate #17984
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17984 +/- ##
==========================================
- Coverage 91.39% 91.36% -0.04%
==========================================
Files 164 164
Lines 49854 49782 -72
==========================================
- Hits 45566 45484 -82
- Misses 4288 4298 +10
Continue to review full report at Codecov.
|
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.
can you add a note in other api changes in 0.22 (this is technially an api change, sort of a trivial one)
@@ -374,6 +374,31 @@ def test_truncate_copy(self): | |||
truncated.values[:] = 5. | |||
assert not (self.tsframe.values[5:11] == 5).any() | |||
|
|||
def test_truncate_nonsortedindex(self): |
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.
can you add a test for series as well (you can also put this test generically in test_generic if its easier)
@@ -6397,6 +6397,10 @@ def truncate(self, before=None, after=None, axis=None, copy=True): | |||
axis = self._get_axis_number(axis) | |||
ax = self._get_axis(axis) | |||
|
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.
add a comment here
69c9324
to
97b662d
Compare
can you rebase |
38acb4f
to
b6c47b0
Compare
b6c47b0
to
a679553
Compare
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.
looks good, except you have lint issues, you can run make lint-diff
and see
pandas/core/generic.py
Outdated
# GH 17935 | ||
# Check that index is sorted | ||
if (not ax.is_monotonic_increasing and | ||
not ax.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.
lint error
doc/source/whatsnew/v0.22.0.txt
Outdated
@@ -46,6 +46,8 @@ Other API Changes | |||
- :class:`Timestamp` will no longer silently ignore invalid ``freq`` arguments (:issue:`5168`) | |||
- :class:`CacheableOffset` and :class:`WeekDay` are no longer available in the ``pandas.tseries.offsets`` module (:issue:`17830`) | |||
- `tseries.frequencies.get_freq_group()` and `tseries.frequencies.DAYS` are removed from the public API (:issue:`18034`) | |||
- :func:`Series.truncate` and :func:`DataFrame.truncate` will raise a ``ValueError`` if the index is not sorted (:issue:`17935`) |
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.
say, rather than a non-helpful KeyError
I updated the whatsnew and think I fixed the lint issue. But since I opened this PR a new |
thanks @reidy-p changing the test for Period was just fine |
git diff upstream/master -u -- "*.py" | flake8 --diff