-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsDatetimeDatetime data dtypeDatetime data dtype
Milestone
Description
Related to #7485.
Currently, DatetimeIndex.asobject raises ValueError when it contains NaT, otherwise PeriodIndex doesn't inconsistently.
I think these should work the same way, and would like to confirm PeriodIndex should raise ValueError, or DatetimeIndex.asobject allows NaT. There may be historical reason, but I'm not sure why DatetimeIndex raises ValueError even though we can create object-dtype Index containning NaT
didx = pd.DatetimeIndex([datetime.datetime(2014, 1, 1), pd.NaT])
didx.asobject
# ValueError: DatetimeIndex with NaT cannot be converted to object
pidx = pd.PeriodIndex(['2014-01', 'NaT'], freq='M')
pidx.asobject
# Index([2014-01, NaT], dtype='object')
Metadata
Metadata
Assignees
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsDatetimeDatetime data dtypeDatetime data dtype