Skip to content

Commit

Permalink
DOC: update the Period.days_in_month docstring (#20297)
Browse files Browse the repository at this point in the history
* Add doctring for Period.days_in_month

* Update added docstring for Period.days_in_month

* Update added docstring for Period.days_in_month
  • Loading branch information
Tushar987 authored and TomAugspurger committed Mar 12, 2018
1 parent 78ded25 commit 6e88d3b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,35 @@ cdef class _Period(object):

@property
def days_in_month(self):
"""
Get the total number of days in the month that this period falls on.
Returns
-------
int
See Also
--------
Period.daysinmonth : Gets the number of days in the month.
DatetimeIndex.daysinmonth : Gets the number of days in the month.
calendar.monthrange : Returns a tuple containing weekday
(0-6 ~ Mon-Sun) and number of days (28-31).
Examples
--------
>>> p = pd.Period('2018-2-17')
>>> p.days_in_month
28
>>> pd.Period('2018-03-01').days_in_month
31
Handles the leap year case as well:
>>> p = pd.Period('2016-2-17')
>>> p.days_in_month
29
"""
base, mult = get_freq_code(self.freq)
return pdays_in_month(self.ordinal, base)

Expand Down

0 comments on commit 6e88d3b

Please sign in to comment.