Skip to content

Commit 7cf458f

Browse files
committed
ENH add date to DatetimeIndex
1 parent e82003f commit 7cf458f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

RELEASE.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pandas 0.11.1
4949
- support datelike columns with a timezone as data_columns (GH2852_)
5050
- table writing performance improvements.
5151
- Add modulo operator to Series, DataFrame
52+
- Add ``date`` method to DatetimeIndex
5253

5354
**API Changes**
5455

@@ -275,7 +276,7 @@ pandas 0.11.0
275276
on rhs (GH3216_)
276277
- Treat boolean values as integers (values 1 and 0) for numeric
277278
operations. (GH2641_)
278-
- Add ``time()`` method to DatetimeIndex (GH3180_)
279+
- Add ``time`` method to DatetimeIndex (GH3180_)
279280
- Return NA when using Series.str[...] for values that are not long enough
280281
(GH3223_)
281282
- Display cursor coordinate information in time-series plots (GH1670_)

pandas/tseries/index.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1319,11 +1319,18 @@ def freqstr(self):
13191319
@property
13201320
def time(self):
13211321
"""
1322-
Returns array of datetime.time. The time of the day
1322+
Returns numpy array of datetime.time. The time part of the Timestamps.
13231323
"""
13241324
# can't call self.map() which tries to treat func as ufunc
13251325
# and causes recursion warnings on python 2.6
1326-
return _algos.arrmap_object(self.asobject, lambda x:x.time())
1326+
return _algos.arrmap_object(self.asobject, lambda x: x.time())
1327+
1328+
@property
1329+
def date(self):
1330+
"""
1331+
Returns numpy array of datetime.date. The date part of the Timestamps.
1332+
"""
1333+
return _algos.arrmap_object(self.asobject, lambda x: x.date())
13271334

13281335

13291336
def normalize(self):

pandas/tseries/tests/test_timeseries.py

+6
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,12 @@ def test_time(self):
18471847
expected = [t.time() for t in rng]
18481848
self.assert_((result == expected).all())
18491849

1850+
def test_date(self):
1851+
rng = pd.date_range('1/1/2000', freq='12H', periods=10)
1852+
result = pd.Index(rng).date
1853+
expected = [t.date() for t in rng]
1854+
self.assert_((result == expected).all())
1855+
18501856

18511857
class TestLegacySupport(unittest.TestCase):
18521858
_multiprocess_can_split_ = True

0 commit comments

Comments
 (0)