-
-
Notifications
You must be signed in to change notification settings - Fork 18.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
Conversation
I might remove or rename |
@TomAugspurger btw, make sure you are rebased on current master. |
(not com.is_sequence(index) and not callable(index)) or | ||
(com.is_list_like(index) and not isinstance(index, MutableMapping)) | ||
) | ||
if is_scalar_or_list: |
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 clear
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.
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...
@@ -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}) |
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.
maybe tests both dict and Series (for the renamer
), and anything else that could be there (e.g. callable
)? you prob already have these tests......
d = {1: 10, 2: 20}
for value in [ d, Series(d) ]:
....
for
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.
These should all covered by test_generic
now. Initially I didn't understand how test_generic
was setup, so I added the test here. I think these tests are all redundant, and could remove them this one and test_rename
above, but I always worry about deleting tests :)
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.
cool np. yeah. hard to stop the propogation of tests :)
Closes pandas-dev#12623 I added com.is_dict_like in pandas-dev#11980 and failed to use it for the `rename` method. Using that now and did some refactoring while I was in there. Added more tests for rename.
51a36af
to
10ea582
Compare
Ok, the tests for the different possible arguments are here. I simplified the stuff with |
thanks @TomAugspurger |
Closes #12623
I added com.is_dict_like in #11980
and failed to use it for the
rename
method. Using that now and didsome refactoring while I was in there. Added more tests for rename.