Skip to content

TST/DOC: apply date() with timezones #14085

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 1 commit into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ There are several time/date properties that one can access from ``Timestamp`` or
second,"The seconds of the datetime"
microsecond,"The microseconds of the datetime"
nanosecond,"The nanoseconds of the datetime"
date,"Returns datetime.date"
time,"Returns datetime.time"
date,"Returns datetime.date (does not contain timezone information)"
time,"Returns datetime.time (does not contain timezone information)"
dayofyear,"The ordinal day of year"
weekofyear,"The week ordinal of the year"
week,"The week ordinal of the year"
Expand Down
14 changes: 13 additions & 1 deletion pandas/tests/series/test_datetime_values.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
# pylint: disable-msg=E1101,W0612

from datetime import datetime
from datetime import datetime, date

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -410,3 +410,15 @@ def test_between(self):
result = s[s.between(s[3], s[17], inclusive=False)]
expected = s[5:16].dropna()
assert_series_equal(result, expected)

def test_date_tz(self):
# GH11757
rng = pd.DatetimeIndex(['2014-04-04 23:56',
'2014-07-18 21:24',
'2015-11-22 22:14'], tz="US/Eastern")
s = Series(rng)
expected = Series([date(2014, 4, 4),
date(2014, 7, 18),
date(2015, 11, 22)])
assert_series_equal(s.dt.date, expected)
assert_series_equal(s.apply(lambda x: x.date()), expected)
3 changes: 2 additions & 1 deletion pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,8 @@ def time(self):
@property
def date(self):
"""
Returns numpy array of datetime.date. The date part of the Timestamps.
Returns numpy array of python datetime.date objects (namely, the date
part of Timestamps without timezone information).
"""
return self._maybe_mask_results(_algos.arrmap_object(
self.asobject.values, lambda x: x.date()))
Expand Down