Categorical fixups by jankatins · Pull Request #7768 · pandas-dev/pandas (original) (raw)

This currently does not work:

cat = pd.Categorical([1,2,3, np.nan], levels=[1,2,3]) cat.levels = [1,2,3, np.nan] cat[1] = np.nan exp = np.array([0,3,2,-1]) self.assert_numpy_array_equal(cat.codes, exp)

I'm not sure if this here is a bug or actually as intended:

In[18]: idx = _ensure_index([1,2,3,np.nan]) 
In[19]: idx
Out[19]: Float64Index([1.0, 2.0, 3.0, nan], dtype='float64')
In[20]: idx.get_indexer([np.nan])
Out[20]: array([-1])