-
-
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 1 commit
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,7 @@ 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") | ||
return libts.ints_to_pydatetime(self.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. I think this needs to be 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. Thanks for the suggestion. That might be it. |
||
|
||
def normalize(self): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,21 @@ def test_roundtrip_pickle_with_tz(self): | |
unpickled = tm.round_trip_pickle(index) | ||
tm.assert_index_equal(index, unpickled) | ||
|
||
def test_date_accessor_with_tz(self): | ||
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 of 2 separate tests, you can have one test |
||
# 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 |
||
index = DatetimeIndex(['2013-01-24 15:01:00+01:00'], | ||
dtype='datetime64[ns, CET]', freq=None) | ||
|
||
assert index.date == np.array(date(2013, 1, 24)) | ||
|
||
def test_date_accessor_without_tz(self): | ||
# GH 21230 | ||
from datetime import date | ||
index = DatetimeIndex(['2013-01-24 15:01:00+01:00'], freq=None) | ||
|
||
assert index.date == np.array(date(2013, 1, 24)) | ||
|
||
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