From bb073b4a3d14ccbd5c7305c068caa4dd69dc300c Mon Sep 17 00:00:00 2001 From: Tushar Date: Mon, 12 Mar 2018 16:44:37 +0530 Subject: [PATCH 1/3] Add doctring for Period.days_in_month --- pandas/_libs/tslibs/period.pyx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 89f38724cde1a..ab17518452a4b 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1270,6 +1270,36 @@ 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 : Returns the number of days in the month. + DatetimeIndex.daysinmonth : Return the number of days in the month. + calendar.monthrange : Return 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 + + >>> import datetime + >>> pd.Period(datetime.datetime.today(), freq= 'B').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) From 8574d2d7847ba010af8e9097d7fd7e5f51e3e9c7 Mon Sep 17 00:00:00 2001 From: Tushar Date: Mon, 12 Mar 2018 21:35:12 +0530 Subject: [PATCH 2/3] Update added docstring for Period.days_in_month --- pandas/_libs/tslibs/period.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index ab17518452a4b..4b02d7ae1d378 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1279,9 +1279,9 @@ cdef class _Period(object): See Also -------- - Period.daysinmonth : Returns the number of days in the month. - DatetimeIndex.daysinmonth : Return the number of days in the month. - calendar.monthrange : Return a tuple containing weekday + 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 From d8bc55931cf57da820a7a0102e8c9b7861b7d126 Mon Sep 17 00:00:00 2001 From: Tushar Date: Mon, 12 Mar 2018 22:03:06 +0530 Subject: [PATCH 3/3] Update added docstring for Period.days_in_month --- pandas/_libs/tslibs/period.pyx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 4b02d7ae1d378..adf4f0569965f 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1286,17 +1286,16 @@ cdef class _Period(object): Examples -------- - >>> p= pd.Period('2018-2-17') + >>> p = pd.Period('2018-2-17') >>> p.days_in_month 28 - >>> import datetime - >>> pd.Period(datetime.datetime.today(), freq= 'B').days_in_month + >>> pd.Period('2018-03-01').days_in_month 31 Handles the leap year case as well: - >>> p= pd.Period('2016-2-17') + >>> p = pd.Period('2016-2-17') >>> p.days_in_month 29 """