Skip to content

Fix TimedeltaIndex constructor fastpath when name is set #10026

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
May 4, 2015
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.16.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/tdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pandas/tseries/tests/test_timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down