DEPR: tz_convert in the Timestamp constructor by mroeschke · Pull Request #23621 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation10 Commits16 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

mroeschke

To have consistent behavior with DatetimeIndex, deprecate the tz_convert behavior of the Timestamp constructor with the tz arg.

Matt Roeschke added 3 commits

November 10, 2018 16:17

@pep8speaks

gfyoung

@codecov

@jreback

lgtm. can you add to the deprecations list, issue #6581

can you replicate your tests on Timestamp on DTI (if they already exist can you xref that test with this issue / PR number)

not sure what is failing.

@jreback

can you rebase, looks fine.

Matt Roeschke added 6 commits

November 12, 2018 15:10

jreback

@@ -967,7 +967,10 @@ def get_loc(self, key, method=None, tolerance=None):
if isinstance(key, datetime):
# needed to localize naive datetimes
key = Timestamp(key, tz=self.tz)
if key.tzinfo is None:
key = Timestamp(key, tz=self.tz)

Choose a reason for hiding this comment

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

I think using .tz_localize() here is more explict

@@ -967,7 +967,10 @@ def get_loc(self, key, method=None, tolerance=None):
if isinstance(key, datetime):
# needed to localize naive datetimes

Choose a reason for hiding this comment

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

also can you modify this comment to reflect the code

@jreback

can you run some asvs to see if we have perf issues

Matt Roeschke added 2 commits

November 16, 2018 10:03

@mroeschke

No regressions according to the asvs.

asv continuous -f 1.1 upstream/master HEAD -b ^timestamp
· Creating environments
· Discovering benchmarks
·· Uninstalling from conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
·· Building aaec0192 for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt.......................................
·· Installing into conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt..
· Running 54 total benchmarks (2 commits * 1 environments * 27 benchmarks)
[  0.00%] · For pandas commit hash aaec0192:
[  0.00%] ·· Building for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt...
[  0.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[  0.00%] ··· Running benchmarks.............................
[  1.85%] ··· timestamp.TimestampAcrossDst.time_replace_across_dst                                      18.7±0.4μs
[  3.70%] ··· timestamp.TimestampConstruction.time_fromordinal                                         1.48±0.03μs
[  5.56%] ··· timestamp.TimestampConstruction.time_fromtimestamp                                       1.72±0.03μs
[  7.41%] ··· timestamp.TimestampConstruction.time_parse_dateutil                                          110±2μs
[  9.26%] ··· timestamp.TimestampConstruction.time_parse_iso8601_no_tz                                 1.78±0.03μs
[ 11.11%] ··· timestamp.TimestampConstruction.time_parse_iso8601_tz                                     15.4±0.6μs
[ 12.96%] ··· timestamp.TimestampConstruction.time_parse_now                                           2.13±0.05μs
[ 14.81%] ··· timestamp.TimestampConstruction.time_parse_today                                         2.18±0.05μs
[ 16.67%] ··· timestamp.TimestampOps.time_replace_None                                             1.89±0.04μs;...
[ 18.52%] ··· timestamp.TimestampOps.time_replace_tz                                               21.0±0.09μs;...
[ 20.37%] ··· timestamp.TimestampOps.time_to_pydatetime                                                584±8ns;...
[ 22.22%] ··· timestamp.TimestampProperties.time_dayofweek                                             271±3ns;...
[ 24.07%] ··· timestamp.TimestampProperties.time_dayofyear                                            337±30ns;...
[ 25.93%] ··· timestamp.TimestampProperties.time_days_in_month                                         287±5ns;...
[ 27.78%] ··· timestamp.TimestampProperties.time_freqstr                                               494±9ns;...
[ 29.63%] ··· timestamp.TimestampProperties.time_is_leap_year                                          272±2ns;...
[ 31.48%] ··· timestamp.TimestampProperties.time_is_month_end                                         380±30ns;...
[ 33.33%] ··· timestamp.TimestampProperties.time_is_month_start                                        270±6ns;...
[ 35.19%] ··· timestamp.TimestampProperties.time_is_quarter_end                                       283±10ns;...
[ 37.04%] ··· timestamp.TimestampProperties.time_is_quarter_start                                      274±6ns;...
[ 38.89%] ··· timestamp.TimestampProperties.time_is_year_end                                           283±4ns;...
[ 40.74%] ··· timestamp.TimestampProperties.time_is_year_start                                         268±1ns;...
[ 42.59%] ··· timestamp.TimestampProperties.time_microsecond                                           214±1ns;...
[ 44.44%] ··· timestamp.TimestampProperties.time_quarter                                               264±6ns;...
[ 46.30%] ··· timestamp.TimestampProperties.time_tz                                                    242±2ns;...
[ 48.15%] ··· timestamp.TimestampProperties.time_week                                                  320±8ns;...
[ 50.00%] ··· timestamp.TimestampProperties.time_weekday_name                                       9.87±0.7μs;...
[ 50.00%] · For pandas commit hash db2066b7:
[ 50.00%] ·· Building for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt..........................................
[ 50.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[ 50.00%] ··· Running benchmarks.............................
[ 51.85%] ··· timestamp.TimestampAcrossDst.time_replace_across_dst                                        21.3±2μs
[ 53.70%] ··· timestamp.TimestampConstruction.time_fromordinal                                          1.70±0.3μs
[ 55.56%] ··· timestamp.TimestampConstruction.time_fromtimestamp                                        1.84±0.2μs
[ 57.41%] ··· timestamp.TimestampConstruction.time_parse_dateutil                                          110±4μs
[ 59.26%] ··· timestamp.TimestampConstruction.time_parse_iso8601_no_tz                                 1.54±0.04μs
[ 61.11%] ··· timestamp.TimestampConstruction.time_parse_iso8601_tz                                     15.1±0.3μs
[ 62.96%] ··· timestamp.TimestampConstruction.time_parse_now                                           1.92±0.07μs
[ 64.81%] ··· timestamp.TimestampConstruction.time_parse_today                                         1.92±0.02μs
[ 66.67%] ··· timestamp.TimestampOps.time_replace_None                                             2.05±0.06μs;...
[ 68.52%] ··· timestamp.TimestampOps.time_replace_tz                                                20.7±0.2μs;...
[ 70.37%] ··· timestamp.TimestampOps.time_to_pydatetime                                               601±30ns;...
[ 72.22%] ··· timestamp.TimestampProperties.time_dayofweek                                             266±6ns;...
[ 74.07%] ··· timestamp.TimestampProperties.time_dayofyear                                             305±5ns;...
[ 75.93%] ··· timestamp.TimestampProperties.time_days_in_month                                         284±9ns;...
[ 77.78%] ··· timestamp.TimestampProperties.time_freqstr                                              508±10ns;...
[ 79.63%] ··· timestamp.TimestampProperties.time_is_leap_year                                          291±9ns;...
[ 81.48%] ··· timestamp.TimestampProperties.time_is_month_end                                         369±10ns;...
[ 83.33%] ··· timestamp.TimestampProperties.time_is_month_start                                        288±6ns;...
[ 85.19%] ··· timestamp.TimestampProperties.time_is_quarter_end                                       290±20ns;...
[ 87.04%] ··· timestamp.TimestampProperties.time_is_quarter_start                                      277±4ns;...
[ 88.89%] ··· timestamp.TimestampProperties.time_is_year_end                                          279±10ns;...
[ 90.74%] ··· timestamp.TimestampProperties.time_is_year_start                                         277±5ns;...
[ 92.59%] ··· timestamp.TimestampProperties.time_microsecond                                          233±10ns;...
[ 94.44%] ··· timestamp.TimestampProperties.time_quarter                                               269±6ns;...
[ 96.30%] ··· timestamp.TimestampProperties.time_tz                                                    242±4ns;...
[ 98.15%] ··· timestamp.TimestampProperties.time_week                                                 320±10ns;...
[100.00%] ··· timestamp.TimestampProperties.time_weekday_name                                       9.57±0.5μs;...

BENCHMARKS NOT SIGNIFICANTLY CHANGED.

jreback

@jreback

@mroeschke mroeschke deleted the timestamp_tz_constructor_depr branch

November 18, 2018 18:30

thoo added a commit to thoo/pandas that referenced this pull request

Nov 19, 2018

@thoo

tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request

Nov 19, 2018

@mroeschke @tm9k1

Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request

Feb 28, 2019

@mroeschke @Pingviinituutti

Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request

Feb 28, 2019

@mroeschke @Pingviinituutti