Description
Born from a gitter conversation with @jorisvandenbossche and @jreback.
As of #10748, it's deprecated to have np.NaN
as a category label. The deprecation warning also fires if None
is a category, but it's unclear whether this is intended behavior, and the error message explicitly refers to NaN, which is confusing.
Code Sample, a copy-pastable example if possible
pd.Categorical.from_codes([0, 1, 2], [None, 'a', 'b'])
Setting NaNs in `categories` is deprecated and will be removed in a future version of pandas.
Expected Output
I wouldn't have expected a warning about NaN
on an array that doesn't contain NaN
.
output of pd.show_versions()
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Linux
OS-release: 4.2.0-16-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 24.0.2
Cython: 0.22.1
numpy: 1.11.1
scipy: 0.15.1
statsmodels: 0.6.1
xarray: None
IPython: 3.2.1
sphinx: 1.3.4
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2016.4
blosc: 1.2.8
bottleneck: 1.0.0
tables: None
numexpr: 2.4.6
matplotlib: 1.4.3
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.8
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.7.3
boto: 2.38.0
pandas_datareader: 0.2.1