-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsPeriodPeriod data typePeriod data type
Milestone
Description
import pandas as pd
dti = pd.date_range("2016-01-01", periods=3)
pi = dti.to_period("D")
dti.astype(pi.dtype) # <- OK
pi.astype(dti.dtype) # <- works but deprecated in #44398
pd.Series(dti).astype(pi.dtype) # <- OK
pd.Series(pi).astype(dti.dtype) # <- raises
In #44398 we deprecated PeriodIndex.astype(dt64). The motivation was that PeriodIndex.astype should be consistent with Series[Period].astype. I chose to deprecate the PeriodIndex behavior instead of allow it in Series.astype bc there's an optional keyword in PeriodIndex.astype that we're deprecating anyway.
I'm having seconds thoughts based on the fact that we do support Series[dt64].astype(period)
, and it seems like these should be able to round-trip.
Metadata
Metadata
Assignees
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsPeriodPeriod data typePeriod data type