Skip to content

DEPR: Deprecate range-based PeriodIndex construction #24354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 28, 2018

Conversation

TomAugspurger
Copy link
Contributor

Closes #20535

@TomAugspurger TomAugspurger added Period Period data type Deprecate Functionality to remove in pandas labels Dec 19, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Dec 19, 2018
@pep8speaks
Copy link

pep8speaks commented Dec 19, 2018

Hello @TomAugspurger! Thanks for updating the PR.

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

Comment last updated on December 28, 2018 at 13:35 Hours UTC

@@ -223,13 +239,13 @@ def __new__(cls, data=None,
verify_integrity = True

if data is None:
result = cls._generate_range(start, end, periods,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, if you passed a bad set of arguments (e.g. forgot freq), then we would warn and then raise an exception.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 19, 2018

Well, that's unfortunate (on master)

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
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24354 into master will decrease coverage by 49.28%.
The diff coverage is 87.5%.

Impacted file tree graph

@@             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%) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/timedeltas.py 40.28% <ø> (-50.15%) ⬇️
pandas/core/indexes/datetimes.py 49.28% <0%> (-47.05%) ⬇️
pandas/util/testing.py 51.42% <100%> (-36.16%) ⬇️
pandas/core/indexes/period.py 41.5% <100%> (-51.6%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/core/categorical.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-98.65%) ⬇️
... and 124 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14c33b0...5473bf1. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24354 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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%> (ø) ⬆️
#single 43% <40%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/timedeltas.py 90.11% <ø> (ø) ⬆️
pandas/util/testing.py 87.84% <100%> (ø) ⬆️
pandas/core/resample.py 97.22% <100%> (ø) ⬆️
pandas/plotting/_converter.py 63.82% <100%> (ø) ⬆️
pandas/core/indexes/period.py 92.71% <100%> (-0.05%) ⬇️
pandas/core/indexes/datetimes.py 96.31% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa1549f...4d0fce2. Read the comment docs.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 19, 2018

5473bf1 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?

@TomAugspurger
Copy link
Contributor Author

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.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 20, 2018

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...

@TomAugspurger
Copy link
Contributor Author

There's something strange going on with the series constructor... I'll open an issue soon.

commit 6a65cbc
Author: Tom Augspurger <[email protected]>
Date:   Thu Dec 20 07:21:34 2018 -0600

    SparseSeries unstack

commit b253674
Author: Tom Augspurger <[email protected]>
Date:   Thu Dec 20 06:40:44 2018 -0600

    BUG: Fix concat(Series[sparse], axis=1)

    * Preserve sparsity
    * Preserve fill value

commit ae026b2
Author: Tom Augspurger <[email protected]>
Date:   Wed Dec 19 21:21:12 2018 -0600

    avoid series constructor

    (cherry picked from commit eb219ac)

commit aa08a6d
Author: Tom Augspurger <[email protected]>
Date:   Wed Dec 19 16:39:04 2018 -0600

    Fixed warnings in asv files

    (cherry picked from commit f566b46)
@TomAugspurger
Copy link
Contributor Author

This is now on top of #24372. Should be mergeable once that's in.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine. should fix the test as I indicated, if you want to merge this and followup pls indicate.

@jreback jreback merged commit 6cfa23e into pandas-dev:master Dec 28, 2018
@jreback
Copy link
Contributor

jreback commented Dec 28, 2018

thanks @TomAugspurger

@TomAugspurger TomAugspurger deleted the depr-period-range-ctor branch December 28, 2018 14:28
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants