diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 6918da60af52d..433118e648827 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -169,11 +169,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.Timedelta.to_numpy \ pandas.Timedelta.total_seconds \ pandas.arrays.TimedeltaArray \ - pandas.Period.freqstr \ - pandas.Period.is_leap_year \ - pandas.Period.month \ - pandas.Period.quarter \ - pandas.Period.year \ pandas.Period.asfreq \ pandas.Period.now \ pandas.arrays.PeriodArray \ diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 0c19dc4e2ec0a..2625caea2040b 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1984,6 +1984,12 @@ cdef class _Period(PeriodMixin): def year(self) -> int: """ Return the year this Period falls on. + + Examples + -------- + >>> period = pd.Period('2022-01', 'M') + >>> period.year + 2022 """ base = self._dtype._dtype_code return pyear(self.ordinal, base) @@ -1992,6 +1998,12 @@ cdef class _Period(PeriodMixin): def month(self) -> int: """ Return the month this Period falls on. + + Examples + -------- + >>> period = pd.Period('2022-01', 'M') + >>> period.month + 1 """ base = self._dtype._dtype_code return pmonth(self.ordinal, base) @@ -2301,6 +2313,12 @@ cdef class _Period(PeriodMixin): def quarter(self) -> int: """ Return the quarter this Period falls on. + + Examples + -------- + >>> period = pd.Period('2022-04', 'M') + >>> period.quarter + 2 """ base = self._dtype._dtype_code return pquarter(self.ordinal, base) @@ -2409,6 +2427,16 @@ cdef class _Period(PeriodMixin): def is_leap_year(self) -> bool: """ Return True if the period's year is in a leap year. + + Examples + -------- + >>> period = pd.Period('2022-01', 'M') + >>> period.is_leap_year + False + + >>> period = pd.Period('2020-01', 'M') + >>> period.is_leap_year + True """ return bool(is_leapyear(self.year)) @@ -2428,6 +2456,11 @@ cdef class _Period(PeriodMixin): def freqstr(self) -> str: """ Return a string representation of the frequency. + + Examples + -------- + >>> pd.Period('2020-01', 'D').freqstr + 'D' """ return self._dtype._freqstr