-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Using DatetimeIndex.date with timezone returns incorrect date #2… #21281
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d27e03e
BUG: Using DatetimeIndex.date with timezone returns incorrect date #2…
jamestran201-alt 0abc96e
Merge branch 'master' of https://github.com/pandas-dev/pandas
jamestran201-alt d962273
Use _local_timestamps() for tz-aware DTI and parametrize test
jamestran201-alt f45a819
Remove redudant code
jamestran201-alt d87106b
Resolve merge conflict
jamestran201-alt f09e8a4
Use _local_timestamps() only for non-UTC DTI, fix documentation, and …
jamestran201-alt 5dddd11
Merge branch 'master' of https://github.com/pandas-dev/pandas
jamestran201-alt ab81279
Fix bug where DTI.time returns a tz-aware Time instead of tz-naive
jamestran201-alt 2ead698
Merge branch 'master' of https://github.com/pandas-dev/pandas
jamestran201-alt 3b15060
Remove redundant code
jamestran201-alt 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 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
""" | ||
Tests for DatetimeIndex timezone-related methods | ||
""" | ||
from datetime import datetime, timedelta, tzinfo | ||
from datetime import datetime, timedelta, tzinfo, date | ||
from distutils.version import LooseVersion | ||
|
||
import pytest | ||
|
@@ -706,6 +706,19 @@ def test_join_utc_convert(self, join_type): | |
assert isinstance(result, DatetimeIndex) | ||
assert result.tz.zone == 'UTC' | ||
|
||
@pytest.mark.parametrize("dtype", [ | ||
None, 'datetime64[ns, CET]', | ||
'datetime64[ns, EST]', 'datetime64[ns, UTC]' | ||
]) | ||
def test_date_accessor(self, dtype): | ||
# Regression test for GH#21230 | ||
expected = np.array([date(2018, 6, 4), pd.NaT], ndmin=1) | ||
|
||
index = DatetimeIndex(['2018-06-04 10:00:00', pd.NaT], dtype=dtype) | ||
result = index.date | ||
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. can u also test .time here |
||
|
||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_dti_drop_dont_lose_tz(self): | ||
# GH#2621 | ||
ind = date_range("2012-12-01", periods=10, tz="utc") | ||
|
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.
is the
ndmin=1
needed here?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.
I needed it to avoid a shape of (1,) when creating a numpy array with only 1 element. I'll remove it now.