Fix categorical from codes nan 21767 by miker985 · Pull Request #21775 · pandas-dev/pandas (original) (raw)

I would slightly prefer to warn for a version when people provide floats. The current changes breaks Categorical.from_codes([1.0, 0.0], ['a', 'b']), which is incorrect, but previously worked.

We can consider checking whether np.all(codes == codes.astype(int)), to detect cases like np.nan.