-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
jreback
merged 16 commits into
pandas-dev:master
from
mroeschke:timestamp_tz_constructor_depr
Nov 18, 2018
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
caa0a62
DEPR: tz_convert in the Timestamp constructor
7c94226
clarify whatsnew
2d13808
Add more backticks
795aa19
add comma after instead, fix test
22cf8a5
refactor constructor with args
766ae93
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
4db92ac
add test for dti
7cb1795
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
4a5b719
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
cfd192d
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
656beff
Handle warnings
96da473
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
3a3b07c
address some warnings?
70ca2cd
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
aaec019
Fix more tz kwarg usage
fa0e39b
Merge remote-tracking branch 'upstream/master' into timestamp_tz_cons…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -937,7 +937,10 @@ def get_value(self, series, key): | |
|
||
# needed to localize naive datetimes | ||
if self.tz is not None: | ||
key = Timestamp(key, tz=self.tz) | ||
if key.tzinfo is not None: | ||
key = Timestamp(key).tz_convert(self.tz) | ||
else: | ||
key = Timestamp(key).tz_localize(self.tz) | ||
|
||
return self.get_value_maybe_box(series, key) | ||
|
||
|
@@ -963,7 +966,11 @@ def get_value(self, series, key): | |
def get_value_maybe_box(self, series, key): | ||
# needed to localize naive datetimes | ||
if self.tz is not None: | ||
key = Timestamp(key, tz=self.tz) | ||
key = Timestamp(key) | ||
if key.tzinfo is not None: | ||
key = key.tz_convert(self.tz) | ||
else: | ||
key = key.tz_localize(self.tz) | ||
elif not isinstance(key, Timestamp): | ||
key = Timestamp(key) | ||
values = self._engine.get_value(com.values_from_object(series), | ||
|
@@ -986,7 +993,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think using .tz_localize() here is more explict |
||
else: | ||
key = Timestamp(key).tz_convert(self.tz) | ||
return Index.get_loc(self, key, method, tolerance) | ||
|
||
elif isinstance(key, timedelta): | ||
|
@@ -1010,7 +1020,11 @@ def get_loc(self, key, method=None, tolerance=None): | |
pass | ||
|
||
try: | ||
stamp = Timestamp(key, tz=self.tz) | ||
stamp = Timestamp(key) | ||
if stamp.tzinfo is not None and self.tz is not None: | ||
stamp = stamp.tz_convert(self.tz) | ||
else: | ||
stamp = stamp.tz_localize(self.tz) | ||
return Index.get_loc(self, stamp, method, tolerance) | ||
except KeyError: | ||
raise KeyError(key) | ||
|
This file contains 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
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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