Skip to content

Commit d12196c

Browse files
DeaMariaLeonim-vinicius
authored and
im-vinicius
committed
DOC: Fixing EX01 - Added examples (pandas-dev#53274)
* Added Examples * corrected code_checks
1 parent dc025d2 commit d12196c

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

ci/code_checks.sh

-5
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
169169
pandas.Timedelta.to_numpy \
170170
pandas.Timedelta.total_seconds \
171171
pandas.arrays.TimedeltaArray \
172-
pandas.Period.freqstr \
173-
pandas.Period.is_leap_year \
174-
pandas.Period.month \
175-
pandas.Period.quarter \
176-
pandas.Period.year \
177172
pandas.Period.asfreq \
178173
pandas.Period.now \
179174
pandas.arrays.PeriodArray \

pandas/_libs/tslibs/period.pyx

+33
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,12 @@ cdef class _Period(PeriodMixin):
19841984
def year(self) -> int:
19851985
"""
19861986
Return the year this Period falls on.
1987+
1988+
Examples
1989+
--------
1990+
>>> period = pd.Period('2022-01', 'M')
1991+
>>> period.year
1992+
2022
19871993
"""
19881994
base = self._dtype._dtype_code
19891995
return pyear(self.ordinal, base)
@@ -1992,6 +1998,12 @@ cdef class _Period(PeriodMixin):
19921998
def month(self) -> int:
19931999
"""
19942000
Return the month this Period falls on.
2001+
2002+
Examples
2003+
--------
2004+
>>> period = pd.Period('2022-01', 'M')
2005+
>>> period.month
2006+
1
19952007
"""
19962008
base = self._dtype._dtype_code
19972009
return pmonth(self.ordinal, base)
@@ -2301,6 +2313,12 @@ cdef class _Period(PeriodMixin):
23012313
def quarter(self) -> int:
23022314
"""
23032315
Return the quarter this Period falls on.
2316+
2317+
Examples
2318+
--------
2319+
>>> period = pd.Period('2022-04', 'M')
2320+
>>> period.quarter
2321+
2
23042322
"""
23052323
base = self._dtype._dtype_code
23062324
return pquarter(self.ordinal, base)
@@ -2409,6 +2427,16 @@ cdef class _Period(PeriodMixin):
24092427
def is_leap_year(self) -> bool:
24102428
"""
24112429
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
24122440
"""
24132441
return bool(is_leapyear(self.year))
24142442

@@ -2428,6 +2456,11 @@ cdef class _Period(PeriodMixin):
24282456
def freqstr(self) -> str:
24292457
"""
24302458
Return a string representation of the frequency.
2459+
2460+
Examples
2461+
--------
2462+
>>> pd.Period('2020-01', 'D').freqstr
2463+
'D'
24312464
"""
24322465
return self._dtype._freqstr
24332466

0 commit comments

Comments
 (0)