diff --git a/doc/source/whatsnew/v0.16.1.txt b/doc/source/whatsnew/v0.16.1.txt index d00ce29fbfe92..08715e9613330 100755 --- a/doc/source/whatsnew/v0.16.1.txt +++ b/doc/source/whatsnew/v0.16.1.txt @@ -192,6 +192,7 @@ Bug Fixes - Bug in ``read_sql_table`` error when reading postgres table with timezone (:issue:`7139`) - Bug in ``DataFrame`` slicing may not retain metadata (:issue:`9776`) - Bug where ``TimdeltaIndex`` were not properly serialized in fixed ``HDFStore`` (:issue:`9635`) +- Bug with ``TimedeltaIndex`` constructor ignoring ``name`` when given another ``TimedeltaIndex`` as data (:issue:`10025`). - Bug in ``DataFrameFormatter._get_formatted_index`` with not applying ``max_colwidth`` to the ``DataFrame`` index (:issue:`7856`) - Bug in ``groupby.apply()`` that would raise if a passed user defined function either returned only ``None`` (for all input). (:issue:`9685`) diff --git a/pandas/tseries/tdi.py b/pandas/tseries/tdi.py index 0f8ba279ec3a6..86c427682c553 100644 --- a/pandas/tseries/tdi.py +++ b/pandas/tseries/tdi.py @@ -140,7 +140,7 @@ def __new__(cls, data=None, unit=None, copy=False, name=None, closed=None, verify_integrity=True, **kwargs): - if isinstance(data, TimedeltaIndex) and freq is None: + if isinstance(data, TimedeltaIndex) and freq is None and name is None: if copy: data = data.copy() return data diff --git a/pandas/tseries/tests/test_timedeltas.py b/pandas/tseries/tests/test_timedeltas.py index bc51e01ca9bdf..faf4e3fa57780 100644 --- a/pandas/tseries/tests/test_timedeltas.py +++ b/pandas/tseries/tests/test_timedeltas.py @@ -949,6 +949,10 @@ def test_constructor_name(self): name='TEST') self.assertEqual(idx.name, 'TEST') + # GH10025 + idx2 = TimedeltaIndex(idx, name='something else') + self.assertEqual(idx2.name, 'something else') + def test_freq_conversion(self): # doc example