-
-
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
Changes from 3 commits
d27e03e
0abc96e
d962273
f45a819
d87106b
f09e8a4
5dddd11
ab81279
2ead698
3b15060
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2040,7 +2040,11 @@ def date(self): | |
Returns numpy array of python datetime.date objects (namely, the date | ||
part of Timestamps without timezone information). | ||
""" | ||
return libts.ints_to_pydatetime(self.normalize().asi8, box="date") | ||
if (self.tz is None): | ||
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. prob need
|
||
return libts.ints_to_pydatetime(self.normalize().asi8, box="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. Do we need the |
||
else: | ||
return libts.ints_to_pydatetime( | ||
self.normalize()._local_timestamps(), box="date") | ||
|
||
def normalize(self): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,18 @@ def test_roundtrip_pickle_with_tz(self): | |
unpickled = tm.round_trip_pickle(index) | ||
tm.assert_index_equal(index, unpickled) | ||
|
||
@pytest.mark.parametrize("test_input", [ | ||
DatetimeIndex(['2013-01-24 15:01:00']), | ||
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. Instead, you could leave the |
||
DatetimeIndex(['2013-01-24 15:01:00'], dtype='datetime64[ns, CET]'), | ||
DatetimeIndex(['2013-01-24 15:01:00'], dtype='datetime64[ns, EST]'), | ||
DatetimeIndex(['2013-01-24 15:01:00'], dtype='datetime64[ns, UTC]') | ||
]) | ||
def test_date_accessor(self, test_input): | ||
# GH 21230 | ||
from datetime import 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. Looks like this is imported at the top already |
||
|
||
assert test_input.date == np.array(date(2013, 1, 24)) | ||
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. Use |
||
|
||
def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self): | ||
# GH7774 | ||
index = date_range('20130101', periods=3, tz='US/Eastern') | ||
|
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.
this should be non-UTC timezone