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

Remove keep_tz kwarg from DatetimeIndex.to_frame #17826

Merged
merged 1 commit into from
Oct 10, 2017

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche added this to the 0.21.0 milestone Oct 9, 2017
@@ -915,46 +915,6 @@ def to_series(self, keep_tz=False):
index=self._shallow_copy(),
name=self.name)

def to_frame(self, index=True, keep_tz=False):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just a code dupe?

Copy link
Member Author

@jorisvandenbossche jorisvandenbossche Oct 9, 2017

Choose a reason for hiding this comment

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

If the keep_tz keyword is removed, then yes, this should be duplicate code.

See #17815 (comment) on removing that keyword or not (you merged the PR before my objection was dismissed or adapted :-))

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm do we need to deprecate?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, because you only merged it a few hours ago (@gfyoung was adding a new method).
(we might consider deprecating it for Index.to_series, but that is another issue.

Copy link
Member

@gfyoung gfyoung Oct 9, 2017

Choose a reason for hiding this comment

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

Not really sure I agree with the choice to remove this argument. It could be confusing to people as to why we support it in one method (to_series) but not the other. Also, your argument as a historical argument was not particularly convincing since you were not 100% sure yourself.

Copy link
Member

Choose a reason for hiding this comment

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

If you think that keep_tz should not be a valid argument, then let's deprecate across the board. I would be okay with that.

Copy link
Member Author

Choose a reason for hiding this comment

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

To illustrate my 'suboptimal behaviour' of above (this is current master):

In [1]: dtidx = pd.date_range("2017-01-01", periods=3, tz='Europe/Brussels')

In [2]: dtidx
Out[2]: 
DatetimeIndex(['2017-01-01 00:00:00+01:00', '2017-01-02 00:00:00+01:00',
               '2017-01-03 00:00:00+01:00'],
              dtype='datetime64[ns, Europe/Brussels]', freq='D')

In [3]: dtidx.to_frame()
Out[3]: 
                                            0
2017-01-01 00:00:00+01:00 2016-12-31 23:00:00
2017-01-02 00:00:00+01:00 2017-01-01 23:00:00
2017-01-03 00:00:00+01:00 2017-01-02 23:00:00

In [5]: dtidx.to_frame().dtypes
Out[5]: 
0    datetime64[ns]
dtype: object

so it was a timezone aware index, but it lost its timezone information in conversion to a dataframe.

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 we can deprecate the existing keep_tz and just always keep it. IIRC I put this in place before we had first class tz support and this was performance (hazy memory though).

@gfyoung do you or @jorisvandenbossche want to add deprecation onto this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I probably won't have time today, so will already merge this one.
I might have time later this week, but that will depend on when the RC is cut.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened an issue for the other one: #17832

@codecov
Copy link

codecov bot commented Oct 9, 2017

Codecov Report

Merging #17826 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17826      +/-   ##
==========================================
- Coverage   91.24%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       49992    49986       -6     
==========================================
- Hits        45613    45598      -15     
- Misses       4379     4388       +9
Flag Coverage Δ
#multiple 89.02% <ø> (-0.01%) ⬇️
#single 40.24% <ø> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 95.58% <ø> (-0.03%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️

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 2ebe085...67e53e5. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 9, 2017

Codecov Report

Merging #17826 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17826      +/-   ##
==========================================
- Coverage   91.24%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       49992    49986       -6     
==========================================
- Hits        45613    45598      -15     
- Misses       4379     4388       +9
Flag Coverage Δ
#multiple 89.02% <ø> (-0.01%) ⬇️
#single 40.24% <ø> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 95.58% <ø> (-0.03%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️

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 2ebe085...67e53e5. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 9, 2017

Codecov Report

Merging #17826 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17826      +/-   ##
==========================================
- Coverage   91.24%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       49992    49986       -6     
==========================================
- Hits        45613    45598      -15     
- Misses       4379     4388       +9
Flag Coverage Δ
#multiple 89.02% <ø> (-0.01%) ⬇️
#single 40.24% <ø> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 95.58% <ø> (-0.03%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️

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 2ebe085...67e53e5. Read the comment docs.

@jreback jreback added Clean Dtype Conversions Unexpected or buggy dtype conversions labels Oct 9, 2017
@jorisvandenbossche jorisvandenbossche merged commit 390f36e into pandas-dev:master Oct 10, 2017
@jorisvandenbossche jorisvandenbossche deleted the to-frame branch October 10, 2017 07:34
ghost pushed a commit to reef-technologies/pandas that referenced this pull request Oct 16, 2017
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants