Skip to content

BUG: #10565 Series.name lost in rolling_* funcions #10659

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
Jul 23, 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
3 changes: 1 addition & 2 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ Bug Fixes
- Bug in ``ExcelReader`` when worksheet is empty (:issue:`6403`)
- Bug in ``Table.select_column`` where name is not preserved (:issue:`10392`)
- Bug in ``offsets.generate_range`` where ``start`` and ``end`` have finer precision than ``offset`` (:issue:`9907`)


- Bug in ``pd.rolling_*`` where ``Series.name`` would be lost in the output (:issue:`10565`)



Expand Down
2 changes: 1 addition & 1 deletion pandas/stats/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def _process_data_structure(arg, kill_inf=True):
values = arg.values
elif isinstance(arg, Series):
values = arg.values
return_hook = lambda v: Series(v, arg.index)
return_hook = lambda v: Series(v, arg.index, name=arg.name)
else:
return_hook = lambda v: v
values = arg
Expand Down
8 changes: 8 additions & 0 deletions pandas/stats/tests/test_moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,14 @@ def test_ewma_halflife_arg(self):
self.assertRaises(Exception, mom.ewma, self.arr, com=9.5, span=20, halflife=50)
self.assertRaises(Exception, mom.ewma, self.arr)

def test_moment_preserve_series_name(self):
# GH 10565
s = Series(np.arange(100), name='foo')
s2 = mom.rolling_mean(s, 30)
s3 = mom.rolling_sum(s, 20)
self.assertEqual(s2.name, 'foo')
self.assertEqual(s3.name, 'foo')

def test_ew_empty_arrays(self):
arr = np.array([], dtype=np.float64)

Expand Down