-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: .rename* not treating Series as mapping #12626
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,13 @@ def test_rename(self): | |
| renamed = renamer.rename({}) | ||
| self.assertEqual(renamed.index.name, renamer.index.name) | ||
|
|
||
| def test_rename_by_series(self): | ||
| s = Series(range(5), name='foo') | ||
| renamer = Series({1: 10, 2: 20}) | ||
|
||
| result = s.rename(renamer) | ||
| expected = Series(range(5), index=[0, 10, 20, 3, 4], name='foo') | ||
| tm.assert_series_equal(result, expected) | ||
|
|
||
| def test_rename_set_name(self): | ||
| s = Series(range(4), index=list('abcd')) | ||
| for name in ['foo', ['foo'], ('foo',)]: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think
lib.isscalar(...) or com.is_list_like(...)is more clearThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com.is_list_like(dict)is True, and I need to treat dicts differently than lists.But if we're going to be raising on
Series.rename(list)anway, I won't have to worry about lists at all...