-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame rename fails with TypeError when give a ChainMap instead of a dict #23859
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
Comments
N.B. I had a quick look at the source code and the problem is in the rename method in generic.py:
The line |
we have an is_dict_like function for this |
OK, I will create a PR when I have some free time. |
@dave-kirby I could fix the issue. I have some free time tomorrow. Do you mind? |
@Ma3aXaKa sorry I am using my work GitHub account so did not see your message over the weekend. If you still have some free time then go ahead. |
Looks to work on master. Could use a test.
|
Example code:
I am trying to rename columns in a DataFrame using mappings from two or more dicts combined using the collections.ChainMap class, but it fails with a TypeError.
The docs for
DataFrame.rename
saysthe ChainMap class should definitely qualify as "dict-like" since it implements the Mapping protocol:
I am using Python 3.6.6 with Pandas 0.23.4.
The text was updated successfully, but these errors were encountered: