Skip to content
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

UnicodeEncodeError when displaying DataFrame with Python 2.7 #200

Open
trankmichael opened this issue Jun 7, 2018 · 3 comments
Open

UnicodeEncodeError when displaying DataFrame with Python 2.7 #200

trankmichael opened this issue Jun 7, 2018 · 3 comments

Comments

@trankmichael
Copy link

trankmichael commented Jun 7, 2018

Environment

  • Operating System:
  • Python Version: 2.7.6
  • How did you install Qgrid: pip
  • Python packages: qgrid==1.0.5, jupyterlab==0.32.1, notebook==5.3.1
  • Jupyter lab packages (if applicable): jupyterlab-manager v0.35.0, qgrid v1.0.5

Description of Issue

  • What did you expect to happen?
    I expected to view the DataFrame similar to __repr_html__.

  • What happened instead?
    An error from qgrid.grid._update_df when it calls .map(str)

'ascii' codec can't encode characters in position 16-18: ordinal not in range(128)

Reproduction Steps

import qgrid
x = pd.DataFrame({'alias': u'柏林市'}, index=[0])

display(x)
qg = qgrid.show_grid(tmp, grid_options={'editable': False})

What steps have you taken to resolve this already?

I tried setting 'editable' : False hoping that that would not call _update_df.

@TimShawver
Copy link
Contributor

Thanks for the report...this seems to be working as expected for me, unless I'm missing something. I tested on both python 2 and 3. For both, I see the following:
screen shot 2018-06-10 at 1 30 25 am

@trankmichael
Copy link
Author

Sorry, it works when '柏林市' is a string but fails with u'柏林市' . I've updated the reproduction steps to:

import qgrid
x = pd.DataFrame({'alias': u'柏林市'}, index=[0])

display(x)
qg = qgrid.show_grid(tmp, grid_options={'editable': False})

@TimShawver
Copy link
Contributor

Thanks. This is fixed in the latest beta (1.0.6b6) which you can install from pypi with pip install qgrid --pre. I'll close this issue once the beta is officially released and available on conda-forge.

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