ERR: Improve error message on non-sorted input with .truncate
State: closed

- [ ] closes #17935
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Datetime
description: Datetime data dtype
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=h1) Report
> Merging [#17984](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c2590b346a7f8e9c0e2e7efa1d5c7318f73fa982?src=pr&el=desc) will **decrease** coverage by `0.03%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/17984/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree)

```diff
@@            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
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.16% <100%> (-0.02%)` | :arrow_down: |
| #single | `39.49% <50%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `95.73% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.91% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `97.14% <0%> (-0.15%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=footer). Last update [c2590b3...f1a7616](https://codecov.io/gh/pandas-dev/pandas/pull/17984?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

can you rebase
I updated the whatsnew and think I fixed the lint issue.

But since I opened this PR a new ``test_truncate`` test has been added to ``pandas/tests/series/test_period.py`` in #17755. This new test fails on my branch because it tries to truncate on a non-sorted index. So I modified the test to sort the index before truncating and now it passes. Alternatively, I could simply check for the new error message ``ValueError: truncate requires a sorted index`` in this test.
thanks @reidy-p 

changing the test for Period was just fine