quantopian / qgrid

An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
Apache License 2.0
3.03k stars 425 forks source link

UnicodeEncodeError when displaying DataFrame with Python 2.7 #200

Open trankmichael opened 6 years ago

trankmichael commented 6 years ago

Environment

'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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.