-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Milestone
Description
In [4]: import pandas as pd, numpy as np
In [5]: sr = pd.Series([1,2, np.nan], dtype="O").astype("category")
...: sr
...:
Out[5]:
0 1.0
1 2.0
2 NaN
dtype: category
Categories (2, int64): [1, 2]
In [6]: sr[0]
Out[6]: 1.0Shouldn't it keep them as ints? Interestingly, pd.Series(["a", 1,2, np.nan], dtype="O").astype("category") doesn't do the conversion.
Metadata
Metadata
Assignees
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves