-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorCategoricalCategorical Data TypeCategorical Data TypeConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array Constructors
Description
dti = pd.date_range("2016-01-01", periods=3)
ci = pd.Categorical(dti._values)
>>> pd.Categorical(["foo"], dtype=ci.dtype)
[NaT]
Categories (3, datetime64[ns]): [2016-01-01, 2016-01-02, 2016-01-03]
Casting "foo" to pd.NaT here makes very little sense to me, and does not match the behavior of any of our other constructors. I'm pretty sure this is why we have to do so much special-casing for Categorical in dtypes.cast and groupby ops.
Suggestion: we change/deprecate the behavior to raise instead of cast.
Metadata
Metadata
Assignees
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorCategoricalCategorical Data TypeCategorical Data TypeConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array Constructors