Skip to content

Bug in DataFrameMapper.get_names: unicode feature names #160

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

Closed
AssafBenDavid opened this issue Jul 26, 2018 · 1 comment
Closed

Bug in DataFrameMapper.get_names: unicode feature names #160

AssafBenDavid opened this issue Jul 26, 2018 · 1 comment

Comments

@AssafBenDavid
Copy link
Contributor

Hi,

When the features returned by a transformer (by _get_feature_names) are unicode strings containing non-ascii characters, get_names throws a UnicodeEncodeError. This is due to line 256 in data frame_mapper.py:
return [name + '_' + str(o) for o in names]
This assumes any object in names can be converted to string using str.
It would be much better to use something like '%s_%s' % (name, o), which returns a unicode when needed. At the end, these strings become DataFrame column names, and DataFrames don't care about unicode indices.

@dukebody
Copy link
Collaborator

dukebody commented Aug 5, 2018

Thank you very much for the report and the contribution! Fixed in #165.

@dukebody dukebody closed this as completed Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants