API: Categorical constructor shouldn't accept scalar for categories · Issue #16022 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
I was surprised to find that Categorical
accepts scalars for categories
.
In [1]: import pandas as pd In [2]: pd.Categorical([1, 2], categories=2) Out[2]: [NaN, 2.0] Categories (1, int64): [2]
AFAICT, this isn't documented, though we explicitly test it here. Am I missing a use-case where this is desirable, or should we just depreciate it and simplify the constructor?
Anyone want to guess what the categories are on pd.Categorical(['a', 'b'], categories='abcd')
:)
cc @JanSchulz