Skip to content

Commit 394e918

Browse files
committed
TST/DOC: apply date() with timezones
1 parent 6645b2b commit 394e918

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

doc/source/timeseries.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ There are several time/date properties that one can access from ``Timestamp`` or
544544
second,"The seconds of the datetime"
545545
microsecond,"The microseconds of the datetime"
546546
nanosecond,"The nanoseconds of the datetime"
547-
date,"Returns datetime.date"
548-
time,"Returns datetime.time"
547+
date,"Returns datetime.date (does not contain timezone information)"
548+
time,"Returns datetime.time (does not contain timezone information)"
549549
dayofyear,"The ordinal day of year"
550550
weekofyear,"The week ordinal of the year"
551551
week,"The week ordinal of the year"

pandas/tests/series/test_datetime_values.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding=utf-8
22
# pylint: disable-msg=E1101,W0612
33

4-
from datetime import datetime
4+
from datetime import datetime, date
55

66
import numpy as np
77
import pandas as pd
@@ -410,3 +410,15 @@ def test_between(self):
410410
result = s[s.between(s[3], s[17], inclusive=False)]
411411
expected = s[5:16].dropna()
412412
assert_series_equal(result, expected)
413+
414+
def test_date_tz(self):
415+
# GH11757
416+
rng = pd.DatetimeIndex(['2014-04-04 23:56',
417+
'2014-07-18 21:24',
418+
'2015-11-22 22:14'], tz="US/Eastern")
419+
s = Series(rng)
420+
expected = Series([date(2014, 4, 4),
421+
date(2014, 7, 18),
422+
date(2015, 11, 22)])
423+
assert_series_equal(s.dt.date, expected)
424+
assert_series_equal(s.apply(lambda x: x.date()), expected)

pandas/tseries/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,8 @@ def time(self):
15971597
@property
15981598
def date(self):
15991599
"""
1600-
Returns numpy array of datetime.date. The date part of the Timestamps.
1600+
Returns numpy array of python datetime.date objects (namely, the date
1601+
part of Timestamps without timezone information).
16011602
"""
16021603
return self._maybe_mask_results(_algos.arrmap_object(
16031604
self.asobject.values, lambda x: x.date()))

0 commit comments

Comments
 (0)