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

ERR: better error message on non-sorted input with .truncate #17935

jreback opened this Issue Oct 21, 2017 · 2 comments


None yet
2 participants

jreback commented Oct 21, 2017

xref #17295

This is correct, but since the doc-string says sorted, we should check this and give a nicer message. (not that should check both .is_monotonic_increasing and decreasing cases, and confirm that the before/after match)

In [8]: rng2 = pd.date_range('2011-01-01', '2012-01-01', freq='W')
   ...: ts2 = pd.Series(np.random.randn(len(rng2)), index=rng2)

In [9]: ts2.truncate(before='2011-11', after='2011-12')
2011-11-06    0.144986
2011-11-13   -1.823425
2011-11-20    1.742315
2011-11-27    0.311337
Freq: W-SUN, dtype: float64

In [10]: ts2.sort_values(ascending=False).truncate(before='2011-11', after='2011-12')
KeyError: Timestamp('2011-11-01 00:00:00')

@jreback jreback added this to the Next Major Release milestone Oct 21, 2017


This comment has been minimized.


jreback commented Oct 21, 2017


This comment has been minimized.


reidy-p commented Oct 21, 2017

@jreback thanks, I'll take a look.

@jreback jreback modified the milestones: Next Major Release, 0.21.1, 0.22.0 Oct 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment