Skip to content

BUG: Index shift drops index name #3986

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
Jun 21, 2013
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/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ pandas 0.11.1
- Indexing with a string with seconds resolution not selecting from a time index (:issue:`3925`)
- csv parsers would loop infinitely if ``iterator=True`` but no ``chunksize`` was
specified (:issue:`3967`), python parser failing with ``chunksize=1``
- Fix index name not propogating when using ``shift``

.. _Gh3616: https://github.com/pydata/pandas/issues/3616

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def shift(self, periods=1, freq=None):
return self

offset = periods * freq
return Index([idx + offset for idx in self])
return Index([idx + offset for idx in self], name=self.name)

def argsort(self, *args, **kwargs):
"""
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def test_shift(self):
shifted = self.dateIndex.shift(1, 'B')
self.assert_(np.array_equal(shifted, self.dateIndex + offsets.BDay()))

shifted.name = 'shifted'
self.assertEqual(shifted.name, shifted.shift(1, 'D').name)

def test_intersection(self):
first = self.strIndex[:20]
second = self.strIndex[:10]
Expand Down