CLN: Move to_period, to_perioddelta up to EA subclasses
State: closed

Should be orthogonal to other outstanding datetimelike EA PRs.

Labels:
name: Datetime
description: Datetime data dtype
name: Period
description: Period data type
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

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

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimelike.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/core/arrays/datetimelike.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimes.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/core/arrays/datetimes.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/datetimelike.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/core/indexes/datetimelike.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/datetimes.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/core/indexes/datetimes.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/period.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/core/indexes/period.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arrays/test_datetimelike.py`](https://github.com/jbrockmendel/pandas/blob/192170b59dda9adda292cbfcac166becd04ceca9/pandas/tests/arrays/test_datetimelike.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23113?src=pr&el=h1) Report
> Merging [#23113](https://codecov.io/gh/pandas-dev/pandas/pull/23113?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/b54e20b4c05727268857dc8cd8acd065f70c6048?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/23113/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23113?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23113      +/-   ##
==========================================
- Coverage   92.19%   92.19%   -0.01%     
==========================================
  Files         169      169              
  Lines       50950    50948       -2     
==========================================
- Hits        46975    46973       -2     
  Misses       3975     3975
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23113?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23113/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `93.24% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23113/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.46% <100%> (-0.04%)` | :arrow_down: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23113/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.4% <100%> (+0.02%)` | :arrow_up: |

------

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

> To what extent do we want to keep our internal EAs to be strict to the EA interface

I've been thinking about it from the other direction: what methods are Index-specific versus making sense on an array?

> But we of course also discuss to expand the EA interface.

There is a growing list of Issues of the form "Add X to EA" that has me convinced we're going to end up with basically the entire ndarray API.  Which makes sense to the extent we want EA (or at least pandas-internal EAs) to be a seamless drop-in replacement.
> There is a growing list of Issues of the form "Add X to EA" that has me convinced we're going to end up with basically the entire ndarray API. Which makes sense to the extent we want EA (or at least pandas-internal EAs) to be a seamless drop-in replacement.

I am with @jbrockmendel here. The EA interface is *going* be used as a drop in replacement for ndarray things, so we ought to have the common / useful methods at least. and certainly ``.repeat`` is one of those.
> we might want to make this private, i dont' think we need to expose to the user

OK.  We can make it private on the Array and keep it public on the Index (could privatize later if really wanted)
Reverted move of repeat/tolist so we can move the ball down the field.
lgtm. The repeat/tolist were fine actually.
I have still one (very minor) outstanding comment: https://github.com/pandas-dev/pandas/pull/23113/files#r225054241, then good to merge for me as well
comment added
@jorisvandenbossche implemented the requested comment.  Are there other outstanding issues here?
@jorisvandenbossche I think this is as green as it gets at the moment.  Would like to explicitly get your OK.
Also the import order that is failing
Thanks!
Thanks!