Closed
Description
We allow tuples in the categories, since they're hashable. But Categorical.__setitem__
has an incorrect check before setting.
In [3]: c = pd.Categorical([(0, 1), (1, 2)])
In [5]: c[0] = (1, 2)
Raises
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-4d3f2e8a3cfd> in <module>()
----> 1 c[0] = (1, 2)
/Users/taugspurger/miniconda3/envs/pandas-0.19.2/lib/python3.5/site-packages/pandas/core/categorical.py in __setitem__(self, key, value)
1652 # something to np.nan
1653 if len(to_add) and not isnull(to_add).all():
-> 1654 raise ValueError("Cannot setitem on a Categorical with a new "
1655 "category, set the categories first")
1656
ValueError: Cannot setitem on a Categorical with a new category, set the categories first
If it's easy, this is worth supporting. If it's complicated, then maybe not.