From 193b467ccf04d7d4cc87b57a23fd4d33a05f1df7 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Wed, 14 Jan 2015 08:54:32 -0500 Subject: [PATCH] BUG: Bug in the returned Series.dt.components index was reset to the default index (GH9247) --- doc/source/whatsnew/v0.16.0.txt | 2 +- pandas/tests/test_series.py | 2 +- pandas/tseries/common.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.16.0.txt b/doc/source/whatsnew/v0.16.0.txt index 365b4ab7ac9d9..5ec0e90383f4c 100644 --- a/doc/source/whatsnew/v0.16.0.txt +++ b/doc/source/whatsnew/v0.16.0.txt @@ -86,7 +86,7 @@ Bug Fixes - Fixed issue using `read_csv` on s3 with Python 3. - Fixed compatibility issue in ``DatetimeIndex`` affecting architectures where ``numpy.int_`` defaults to ``numpy.int32`` (:issue:`8943`) - Bug in Panel indexing with an object-like (:issue:`9140`) - +- Bug in the returned ``Series.dt.components`` index was reset to the default index (:issue:`9247`) diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 9b072e2f62968..6faf6229b6d3b 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -142,7 +142,7 @@ def compare(s, name): tm.assert_series_equal(result, expected) # timedeltaindex - for s in [Series(timedelta_range('1 day',periods=5)), + for s in [Series(timedelta_range('1 day',periods=5),index=list('abcde')), Series(timedelta_range('1 day 01:23:45',periods=5,freq='s')), Series(timedelta_range('2 days 01:23:45.012345',periods=5,freq='ms'))]: for prop in ok_for_td: diff --git a/pandas/tseries/common.py b/pandas/tseries/common.py index f12e0263bcf0c..c953c0961a596 100644 --- a/pandas/tseries/common.py +++ b/pandas/tseries/common.py @@ -139,7 +139,7 @@ def to_pytimedelta(self): @property def components(self): - return self.values.components + return self.values.components.set_index(self.index) TimedeltaProperties._add_delegate_accessors(delegate=TimedeltaIndex, accessors=TimedeltaIndex._datetimelike_ops,