Skip to content

Commit 6e88d3b

Browse files
Tushar987TomAugspurger
authored andcommitted
DOC: update the Period.days_in_month docstring (#20297)
* Add doctring for Period.days_in_month * Update added docstring for Period.days_in_month * Update added docstring for Period.days_in_month
1 parent 78ded25 commit 6e88d3b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pandas/_libs/tslibs/period.pyx

+29
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,35 @@ cdef class _Period(object):
12891289

12901290
@property
12911291
def days_in_month(self):
1292+
"""
1293+
Get the total number of days in the month that this period falls on.
1294+
1295+
Returns
1296+
-------
1297+
int
1298+
1299+
See Also
1300+
--------
1301+
Period.daysinmonth : Gets the number of days in the month.
1302+
DatetimeIndex.daysinmonth : Gets the number of days in the month.
1303+
calendar.monthrange : Returns a tuple containing weekday
1304+
(0-6 ~ Mon-Sun) and number of days (28-31).
1305+
1306+
Examples
1307+
--------
1308+
>>> p = pd.Period('2018-2-17')
1309+
>>> p.days_in_month
1310+
28
1311+
1312+
>>> pd.Period('2018-03-01').days_in_month
1313+
31
1314+
1315+
Handles the leap year case as well:
1316+
1317+
>>> p = pd.Period('2016-2-17')
1318+
>>> p.days_in_month
1319+
29
1320+
"""
12921321
base, mult = get_freq_code(self.freq)
12931322
return pdays_in_month(self.ordinal, base)
12941323

0 commit comments

Comments
 (0)