From bd7ef4826ce2a2cc97dd0f4105ae2752c7a33f8b Mon Sep 17 00:00:00 2001 From: HimanshuAwasthi95 Date: Tue, 13 Mar 2018 00:58:16 +0530 Subject: [PATCH 1/3] Update Period.hour docstring --- pandas/_libs/tslibs/period.pyx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 7763fe7b9008d..ef77f25afacba 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1241,6 +1241,24 @@ cdef class _Period(object): @property def hour(self): + """ + Get hours of a day that a Period falls on. + + Returns + ------- + int + + See Also + -------- + Period.minute : Get the minute of hour + Period.second : Get the second of hour + + Examples + -------- + >>> p = pd.Period("2018-03-11 13:03:12.050000") + >>> p.hour + 13 + """ base, mult = get_freq_code(self.freq) return phour(self.ordinal, base) From b3d5efef5c816f5a05c690ca5f7202b4a5b15937 Mon Sep 17 00:00:00 2001 From: HimanshuAwasthi95 Date: Tue, 13 Mar 2018 01:48:10 +0530 Subject: [PATCH 2/3] update required changes --- pandas/_libs/tslibs/period.pyx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index ef77f25afacba..0d96c3dfd0952 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1242,22 +1242,29 @@ cdef class _Period(object): @property def hour(self): """ - Get hours of a day that a Period falls on. + Get hours of the day component of the Period. Returns ------- - int + int + The hour as an integer, between 0 and 23. See Also -------- - Period.minute : Get the minute of hour - Period.second : Get the second of hour + Period.minute : Get the minute of the Period. + Period.second : Get the second of the Period. Examples -------- >>> p = pd.Period("2018-03-11 13:03:12.050000") >>> p.hour 13 + + Period longer than a day + + >>> p = pd.Period("2018-03-11", freq="M") + >>> p.hour + 0 """ base, mult = get_freq_code(self.freq) return phour(self.ordinal, base) From c968c6d7ab2c3187532a09f31cc919cca7d0cdad Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 12 Mar 2018 16:04:20 -0500 Subject: [PATCH 3/3] Update period.pyx --- 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 0d96c3dfd0952..d5241e5a706f5 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1242,7 +1242,7 @@ cdef class _Period(object): @property def hour(self): """ - Get hours of the day component of the Period. + Get the hour of the day component of the Period. Returns ------- @@ -1251,8 +1251,8 @@ cdef class _Period(object): See Also -------- - Period.minute : Get the minute of the Period. - Period.second : Get the second of the Period. + Period.second : Get the second component of the Period. + Period.minute : Get the minute component of the Period. Examples --------