Modernize indexes.timedeltas, indexes.datetimeindex
State: closed

Two things here.  They should be separate PRs, but so it goes.

indexes.datetimes and indexes.periods use a _field_accessor pattern to define several properties in their index classes.  This updates TimedeltaIndex to use the same pattern, getting rid of the `_get_field` method that was used before.

indexes.datetimes has a _utc() function that I think is designed to lazily import pytz.  That ship has sailed elsewhere, so this removes that extra call.


Labels:
name: Clean

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

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

```diff
@@            Coverage Diff             @@
##           master   #18161      +/-   ##
==========================================
+ Coverage   91.41%   91.41%   +<.01%     
==========================================
  Files         163      163              
  Lines       50132    50123       -9     
==========================================
- Hits        45827    45821       -6     
+ Misses       4305     4302       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.22% <100%> (+0.02%)` | :arrow_up: |
| #single | `40.34% <57.89%> (-0.05%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `91.15% <100%> (-0.04%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.48% <100%> (-0.04%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/18161?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.2% <0%> (+1.81%)` | :arrow_up: |

------

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

thsnks