Closed
Description
Environment
- Operating System: Linux
- Python Version: 3.6.5
- How did you install Qgrid:
pip
- Python packages:
qgrid==1.0.5
notebook==5.3.0
jupyterlab==0.32.1
- Jupyter lab packages (if applicable):
$ jupyter labextension list
@jupyter-widgets/jupyterlab-manager
@jupyter-widgets/jupyterlab-manager v0.35.0 enabled OK
qgrid
qgrid v1.0.5 enabled OK
Description of Issue
- What did you expect to happen?
Being able to select a categorical data containing arbitrary text, including quotes. In particular, I was expecting to set a category item among `{"ConL1", "ConL2", "ConL3", "ConLS", "ConLS'"}.
- What happened instead?
- When I encountered this bug for the first time, I got an error popup, and the following traceback in the server log:
[IPKernelApp] ERROR | Error occurred while attempting to edit the DataFrame. Check the notebook server logs for more information.
Traceback (most recent call last):
File "/home/althonos/.local/lib/python3.6/site-packages/qgrid/grid.py", line 1224, in _handle_qgrid_msg_helper
self._df.loc[location] = val_to_set
File "/usr/lib/python3.6/site-packages/pandas/core/indexing.py", line 189, in __setitem__
self._setitem_with_indexer(indexer, value)
File "/usr/lib/python3.6/site-packages/pandas/core/indexing.py", line 615, in _setitem_with_indexer
setter(item, value)
File "/usr/lib/python3.6/site-packages/pandas/core/indexing.py", line 539, in setter
s._data = s._data.setitem(indexer=pi, value=v)
File "/usr/lib/python3.6/site-packages/pandas/core/internals.py", line 3693, in setitem
return self.apply('setitem', **kwargs)
File "/usr/lib/python3.6/site-packages/pandas/core/internals.py", line 3581, in apply
applied = getattr(b, f)(**kwargs)
File "/usr/lib/python3.6/site-packages/pandas/core/internals.py", line 1934, in setitem
self.values[indexer] = value
File "/usr/lib/python3.6/site-packages/pandas/core/arrays/categorical.py", line 1982, in __setitem__
raise ValueError("Cannot setitem on a Categorical with a new "
ValueError: Cannot setitem on a Categorical with a new category, set the categories first
- When trying to come with a reproducible test case, I could only reach a point where the update would simply not happen, but no error would be raised.
Reproduction Steps
- Create a notebook with the following cell:
import qgrid
import pandas
df = pandas.DataFrame({'test': pandas.Categorical(['', ''], categories={'', "Hi", "'Hello'"})})
qgrid.QGridWidget(df=df, show_toolbar=True)
- Try to set the value of the
test
column to'Hello'
: nothing is updated (the cell stays empty).
Metadata
Metadata
Assignees
Labels
No labels