@@ -1984,6 +1984,12 @@ cdef class _Period(PeriodMixin):
1984
1984
def year(self ) -> int:
1985
1985
"""
1986
1986
Return the year this Period falls on.
1987
+
1988
+ Examples
1989
+ --------
1990
+ >>> period = pd.Period(' 2022-01' , ' M' )
1991
+ >>> period.year
1992
+ 2022
1987
1993
"""
1988
1994
base = self ._dtype._dtype_code
1989
1995
return pyear(self.ordinal , base )
@@ -1992,6 +1998,12 @@ cdef class _Period(PeriodMixin):
1992
1998
def month(self ) -> int:
1993
1999
"""
1994
2000
Return the month this Period falls on.
2001
+
2002
+ Examples
2003
+ --------
2004
+ >>> period = pd.Period(' 2022-01' , ' M' )
2005
+ >>> period.month
2006
+ 1
1995
2007
"""
1996
2008
base = self ._dtype._dtype_code
1997
2009
return pmonth(self.ordinal , base )
@@ -2301,6 +2313,12 @@ cdef class _Period(PeriodMixin):
2301
2313
def quarter(self ) -> int:
2302
2314
"""
2303
2315
Return the quarter this Period falls on.
2316
+
2317
+ Examples
2318
+ --------
2319
+ >>> period = pd.Period(' 2022-04' , ' M' )
2320
+ >>> period.quarter
2321
+ 2
2304
2322
"""
2305
2323
base = self ._dtype._dtype_code
2306
2324
return pquarter(self.ordinal , base )
@@ -2409,6 +2427,16 @@ cdef class _Period(PeriodMixin):
2409
2427
def is_leap_year(self ) -> bool:
2410
2428
"""
2411
2429
Return True if the period's year is in a leap year.
2430
+
2431
+ Examples
2432
+ --------
2433
+ >>> period = pd.Period(' 2022-01' , ' M' )
2434
+ >>> period.is_leap_year
2435
+ False
2436
+
2437
+ >>> period = pd.Period(' 2020-01' , ' M' )
2438
+ >>> period.is_leap_year
2439
+ True
2412
2440
"""
2413
2441
return bool(is_leapyear(self.year ))
2414
2442
@@ -2428,6 +2456,11 @@ cdef class _Period(PeriodMixin):
2428
2456
def freqstr (self ) -> str:
2429
2457
"""
2430
2458
Return a string representation of the frequency.
2459
+
2460
+ Examples
2461
+ --------
2462
+ >>> pd.Period('2020-01', 'D').freqstr
2463
+ 'D'
2431
2464
"""
2432
2465
return self._dtype._freqstr
2433
2466
0 commit comments