Skip to content

Commit a69f7b7

Browse files
committed
Add factorize method in period.py
1 parent 19621e6 commit a69f7b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/arrays/period.py

+10
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,16 @@ def _values_for_argsort(self):
817817
def _values_for_factorize(self):
818818
return np.asarray(self), np.nan
819819

820+
def factorize(self, na_sentinel=-1):
821+
from pandas.core.algorithms import factorize
822+
823+
arr, na_value = self._values_for_factorize()
824+
825+
labels, uniques = factorize(arr, na_sentinel=na_sentinel)
826+
827+
uniques = period_array(uniques)
828+
return labels, uniques
829+
820830

821831
PeriodArray._add_comparison_ops()
822832

0 commit comments

Comments
 (0)