@@ -104,7 +104,7 @@ def f(self):
104
104
return property (f )
105
105
106
106
107
- class PeriodArray (dtl .DatelikeOps ):
107
+ class PeriodArray (dtl .DatelikeOps , libperiod . PeriodMixin ):
108
108
"""
109
109
Pandas ExtensionArray for storing Period data.
110
110
@@ -500,7 +500,7 @@ def to_timestamp(self, freq=None, how: str = "start") -> DatetimeArray:
500
500
return (self + self .freq ).to_timestamp (how = "start" ) - adjust
501
501
502
502
if freq is None :
503
- freq = self ._get_to_timestamp_base ()
503
+ freq = self ._dtype . _get_to_timestamp_base ()
504
504
base = freq
505
505
else :
506
506
freq = Period ._maybe_convert_freq (freq )
@@ -606,8 +606,7 @@ def asfreq(self, freq=None, how: str = "E") -> PeriodArray:
606
606
607
607
freq = Period ._maybe_convert_freq (freq )
608
608
609
- # error: "BaseOffset" has no attribute "_period_dtype_code"
610
- base1 = self .freq ._period_dtype_code # type: ignore[attr-defined]
609
+ base1 = self ._dtype ._dtype_code
611
610
base2 = freq ._period_dtype_code
612
611
613
612
asi8 = self .asi8
@@ -884,56 +883,6 @@ def _check_timedeltalike_freq_compat(self, other):
884
883
885
884
raise raise_on_incompatible (self , other )
886
885
887
- # ------------------------------------------------------------------
888
- # TODO: See if we can re-share this with Period
889
-
890
- def _get_to_timestamp_base (self ) -> int :
891
- """
892
- Return frequency code group used for base of to_timestamp against
893
- frequency code.
894
-
895
- Return day freq code against longer freq than day.
896
- Return second freq code against hour between second.
897
-
898
- Returns
899
- -------
900
- int
901
- """
902
- base = self ._dtype ._dtype_code
903
- if base < FreqGroup .FR_BUS .value :
904
- return FreqGroup .FR_DAY .value
905
- elif FreqGroup .FR_HR .value <= base <= FreqGroup .FR_SEC .value :
906
- return FreqGroup .FR_SEC .value
907
- return base
908
-
909
- @property
910
- def start_time (self ) -> DatetimeArray :
911
- return self .to_timestamp (how = "start" )
912
-
913
- @property
914
- def end_time (self ) -> DatetimeArray :
915
- return self .to_timestamp (how = "end" )
916
-
917
- def _require_matching_freq (self , other , base : bool = False ) -> None :
918
- # See also arrays.period.raise_on_incompatible
919
- if isinstance (other , BaseOffset ):
920
- other_freq = other
921
- else :
922
- other_freq = other .freq
923
-
924
- if base :
925
- condition = self .freq .base != other_freq .base
926
- else :
927
- condition = self .freq != other_freq
928
-
929
- if condition :
930
- msg = DIFFERENT_FREQ .format (
931
- cls = type (self ).__name__ ,
932
- own_freq = self .freqstr ,
933
- other_freq = other_freq .freqstr ,
934
- )
935
- raise IncompatibleFrequency (msg )
936
-
937
886
938
887
def raise_on_incompatible (left , right ):
939
888
"""
0 commit comments