BUG: Cleanup timedelta offset
State: closed

- [x] closes #21762
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Fixed to use same unit parsing logic in `Timedelta` and `to_timedelta`. Needs to update after #23264 and #23259.





Labels:
name: Bug
name: Timedelta
description: Timedelta data type

Comments:
Hello @sinhrks! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/tools/timedeltas.py`](https://github.com/sinhrks/pandas/blob/5785045d6e12ddf9df6feece21ff7add253c5ba0/pandas/core/tools/timedeltas.py) !

 - There are no PEP8 issues in the file [`pandas/tests/scalar/timedelta/test_timedelta.py`](https://github.com/sinhrks/pandas/blob/5785045d6e12ddf9df6feece21ff7add253c5ba0/pandas/tests/scalar/timedelta/test_timedelta.py) !


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

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

```diff
@@            Coverage Diff             @@
##           master   #23439      +/-   ##
==========================================
- Coverage   92.23%   92.23%   -0.01%     
==========================================
  Files         161      161              
  Lines       51197    51189       -8     
==========================================
- Hits        47220    47212       -8     
  Misses       3977     3977
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.26% <100%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23439?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/tools/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/23439/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvdGltZWRlbHRhcy5weQ==) | `98.18% <100%> (-0.24%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23439?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/23439?src=pr&el=footer). Last update [24ab22f...04f3ceb](https://codecov.io/gh/pandas-dev/pandas/pull/23439?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks @sinhrks 
Personally, I think we should make a distinction between which units are accepted for the `unit` parameter, and which are parsed inside a string. 

For parsing a string, it is fine to accept both '15m', '15min', '15minute', '15minutes and '15T'. But for the `unit` keyword, is it needed to allow this flexibility? 
I would say that just the standard units (the numpy ones, as we had now) + maybe the abbreviations as used in our freq strings should be enough no? (so 'm' and 'T')

(and to be clear, the rest of this PR, fixing the inconsistency of what strings are parsed is of course totally fine!)
@jorisvandenbossche I kept existing behaviour, but it is better to clarify the policy. It should be consistent with period also.

```
pd.Period('2011-01', freq='min')
# Period('2011-01-01 00:00', 'T')

pd.Period('2011-01', freq='hour')
# ValueError: Invalid frequency: hour
```