Skip to content
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

DEPR: deprecate default of keep_tz=False of DatetimeIndex.to_series #23739

Merged
merged 3 commits into from
Nov 16, 2018

Conversation

jorisvandenbossche
Copy link
Member

Closes #17832

@jorisvandenbossche jorisvandenbossche added Datetime Datetime data dtype Deprecate Functionality to remove in pandas labels Nov 16, 2018
@jorisvandenbossche jorisvandenbossche added this to the 0.24.0 milestone Nov 16, 2018
@pep8speaks
Copy link

Hello @jorisvandenbossche! Thanks for submitting the PR.

@@ -500,6 +500,12 @@ def to_series(self, keep_tz=False, index=None, name=None):

Series will have a datetime64[ns] dtype. TZ aware
objects will have the tz removed.

.. versionchanged:: 0.24
The default value will change to True in a future release.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just remove the keyword in the future, we don't need to offer this additional funtionaility, this was mainly for backwards compat originally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, my idea is to remove it in the future. But I think we first need to deprecate the behaviour, so people can switch, and once that is done, we can deprecate the full keyword.
See also some of the notes about it in #17832

Copy link
Member Author

Choose a reason for hiding this comment

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

But, we can of course already discourage the 'False' behaviour, by also deprecating that (only allowing keep_tz=True

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I think i would deprecate any non-None

with tm.assert_produces_warning(FutureWarning):
result = idx.to_series(index=[0, 1])
tm.assert_series_equal(
result, expected.dt.tz_convert('UTC').dt.tz_localize(None))
Copy link
Member Author

Choose a reason for hiding this comment

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

This might seem a strange file to put this test, but as far as I found, this is actually the only place where this behaviour was tested. So I decided to put it here, so only one test needs to be updated when we remove the deprecation.

@jreback
Copy link
Contributor

jreback commented Nov 16, 2018

lgtm.

@jreback
Copy link
Contributor

jreback commented Nov 16, 2018

can you add to the deprecation issue #6581

@codecov
Copy link

codecov bot commented Nov 16, 2018

Codecov Report

Merging #23739 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23739      +/-   ##
==========================================
+ Coverage   92.25%   92.25%   +<.01%     
==========================================
  Files         161      161              
  Lines       51383    51388       +5     
==========================================
+ Hits        47404    47409       +5     
  Misses       3979     3979
Flag Coverage Δ
#multiple 90.64% <100%> (ø) ⬆️
#single 42.31% <16.66%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 96.14% <100%> (+0.02%) ⬆️
pandas/io/parsers.py 95.55% <0%> (ø) ⬆️

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 e98032d...d1390ed. Read the comment docs.

@jreback jreback merged commit db2066b into pandas-dev:master Nov 16, 2018
@jreback
Copy link
Contributor

jreback commented Nov 16, 2018

thanks @jorisvandenbossche

@jbrockmendel
Copy link
Member

I'm looking at enforcing this deprecation now. Should we just change the default or go ahead and rip out keep_tz altogether?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: deprecate keep_tz keyword in DatetimeIndex.to_series
4 participants