Closed
Description
Avoid an astype(object).
diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py
index 5a75f2706..12191ad89 100644
--- a/pandas/core/arrays/period.py
+++ b/pandas/core/arrays/period.py
@@ -216,6 +216,10 @@ class PeriodArray(dtl.DatetimeLikeArrayMixin, ExtensionArray):
ordinals = libperiod.extract_ordinals(periods, freq)
return cls(ordinals, freq=freq)
+ def unique(self):
+ from pandas.core.algorithms import unique
+ return type(self)(unique(self.asi8), self.freq)
+
def _values_for_factorize(self):
return self.asi8, iNaT
should work.