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: tz_convert in the Timestamp constructor #23621

Merged
merged 16 commits into from
Nov 18, 2018

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Nov 11, 2018

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

@pep8speaks
Copy link

Hello @mroeschke! Thanks for submitting the PR.

@gfyoung gfyoung added Dependencies Required and optional dependencies Deprecate Functionality to remove in pandas Datetime Datetime data dtype Timezones Timezone data dtype and removed Dependencies Required and optional dependencies labels Nov 11, 2018
@codecov
Copy link

codecov bot commented Nov 11, 2018

Codecov Report

Merging #23621 into master will increase coverage by <.01%.
The diff coverage is 96.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23621      +/-   ##
==========================================
+ Coverage   92.23%   92.23%   +<.01%     
==========================================
  Files         161      161              
  Lines       51408    51427      +19     
==========================================
+ Hits        47416    47434      +18     
- Misses       3992     3993       +1
Flag Coverage Δ
#multiple 90.62% <96.15%> (ø) ⬆️
#single 42.29% <23.07%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 96.2% <100%> (+0.05%) ⬆️
pandas/core/arrays/datetimes.py 98.49% <100%> (ø) ⬆️
pandas/core/generic.py 96.83% <100%> (ø) ⬆️
pandas/io/formats/format.py 97.76% <66.66%> (-0.12%) ⬇️

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 24bce1a...fa0e39b. Read the comment docs.

@jreback jreback added this to the 0.24.0 milestone Nov 11, 2018
@jreback
Copy link
Contributor

jreback commented Nov 11, 2018

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

jreback commented Nov 12, 2018

can you rebase, looks fine.

@@ -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)
Copy link
Contributor

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

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

jreback commented Nov 16, 2018

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

@mroeschke
Copy link
Member Author

mroeschke commented Nov 16, 2018

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 merged commit e2c4f04 into pandas-dev:master Nov 18, 2018
@jreback
Copy link
Contributor

jreback commented Nov 18, 2018

thanks @mroeschke

@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
…fixed

* upstream/master: (46 commits)
  DEPS: bump xlrd min version to 1.0.0 (pandas-dev#23774)
  BUG: Don't warn if default conflicts with dialect (pandas-dev#23775)
  BUG: Fixing memory leaks in read_csv (pandas-dev#23072)
  TST: Extend datetime64 arith tests to array classes, fix several broken cases (pandas-dev#23771)
  STYLE: Specify bare exceptions in pandas/tests (pandas-dev#23370)
  ENH: between_time, at_time accept axis parameter (pandas-dev#21799)
  PERF: Use is_utc check to improve performance of dateutil UTC in DatetimeIndex methods (pandas-dev#23772)
  CLN: io/formats/html.py: refactor (pandas-dev#22726)
  API: Make Categorical.searchsorted returns a scalar when supplied a scalar (pandas-dev#23466)
  TST: Add test case for GH14080 for overflow exception (pandas-dev#23762)
  BUG: Don't extract header names if none specified (pandas-dev#23703)
  BUG: Index.str.partition not nan-safe (pandas-dev#23558) (pandas-dev#23618)
  DEPR: tz_convert in the Timestamp constructor (pandas-dev#23621)
  PERF: Datetime/Timestamp.normalize for timezone naive datetimes (pandas-dev#23634)
  TST: Use new arithmetic fixtures, parametrize many more tests (pandas-dev#23757)
  REF/TST: Add more pytest idiom to parsers tests (pandas-dev#23761)
  DOC: Add ignore-deprecate argument to validate_docstrings.py (pandas-dev#23650)
  ENH: update pandas-gbq to 0.8.0, adds credentials arg (pandas-dev#23662)
  DOC: Improve error message to show correct order (pandas-dev#23652)
  ENH: Improve error message for empty object array (pandas-dev#23718)
  ...
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
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
Datetime Datetime data dtype Deprecate Functionality to remove in pandas Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: tz_convert within DatetimeIndex constructor
4 participants