DEPR: Deprecate range-based PeriodIndex construction
State: closed

Closes https://github.com/pandas-dev/pandas/issues/20535

Labels:
name: Period
description: Period data type
name: Deprecate
description: Functionality to remove in pandas

Comments:
Hello @TomAugspurger! Thanks for updating the PR.









































Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on December 28, 2018 at 13:35 Hours UTC
Well, that's unfortunate (on master)

```python
In [3]: pd.period_range(start='2000', periods=2)
Out[3]: PeriodIndex(['2000-01-01', '2000-01-02'], dtype='period[D]', freq='D')

In [4]: pd.PeriodIndex(start='2000', periods=2)
Out[4]: PeriodIndex(['2000', '2001'], dtype='period[A-DEC]', freq='A-DEC')
```
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24354?src=pr&el=h1) Report
> Merging [#24354](https://codecov.io/gh/pandas-dev/pandas/pull/24354?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/14c33b0e531ba955ae20a6e37750261133e5391e?src=pr&el=desc) will **decrease** coverage by `49.28%`.
> The diff coverage is `87.5%`.

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

```diff
@@             Coverage Diff             @@
##           master   #24354       +/-   ##
===========================================
- Coverage   92.29%   43.01%   -49.29%     
===========================================
  Files         162      162               
  Lines       51808    51812        +4     
===========================================
- Hits        47817    22287    -25530     
- Misses       3991    29525    +25534
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `43.01% <87.5%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24354?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `40.28% <ø> (-50.15%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `49.28% <0%> (-47.05%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `51.42% <100%> (-36.16%)` | :arrow_down: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `41.5% <100%> (-51.6%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-98.65%)` | :arrow_down: |
| ... and [124 more](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree-more) | |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #24354      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         163      163              
  Lines       51969    51980      +11     
==========================================
+ Hits        47968    47978      +10     
- Misses       4001     4002       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.7% <100%> (ø)` | :arrow_up: |
| #single | `43% <40%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24354?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.11% <ø> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.84% <100%> (ø)` | :arrow_up: |
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `97.22% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.82% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `92.71% <100%> (-0.05%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24354/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.31% <100%> (ø)` | :arrow_up: |

------

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

5473bf1d43acbb7dd33a56d083e8530a71f2d3c7 attempts to preserve the behavior of `pd.date_range`, while giving a good warning message.

Question: This introduces a difference between

1. `period_range("2000", periods=2)`
2. `period_range(pd.Period("2000", freq="A-JAN"), periods=2)`

The latter will have freq `A-JAN`. We're OK with that, right?
Does anyone see the actual failure in https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=5567

My latest commit fixes some warnings... but I don't think that's what caused the failure.
Ah, just search the log for "failed". The sparse get_dummies is timing out:

```
2018-12-19T23:09:41.8974791Z [ 33.17%] ··· reshape.GetDummies.time_get_dummies_1d_sparse               failed
```

I must have messed something up...
There's something strange going on with the series constructor... I'll open an issue soon.
This is now on top of https://github.com/pandas-dev/pandas/pull/24372. Should be mergeable once that's in.
thanks @TomAugspurger