From 15e468047f65147bb83004aefbc38be6b89e6f0b Mon Sep 17 00:00:00 2001 From: Siddhartha Gandhi Date: Thu, 17 Nov 2022 22:07:26 -0500 Subject: [PATCH 1/2] Update start/end parameter documentation for BusinessHour and CustomBusinessHour to mention allowed input types of time and list of str/time --- pandas/_libs/tslibs/offsets.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index d0f73b44e835f..14dd2d93e0e68 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1615,9 +1615,9 @@ cdef class BusinessHour(BusinessMixin): Normalize start/end dates to midnight before generating date range. weekmask : str, Default 'Mon Tue Wed Thu Fri' Weekmask of valid business days, passed to ``numpy.busdaycalendar``. - start : str, default "09:00" + start : str, time, or list of str/time, default "09:00" Start time of your custom business hour in 24h format. - end : str, default: "17:00" + end : str, time, or list of str/time, default: "17:00" End time of your custom business hour in 24h format. Examples @@ -3619,9 +3619,9 @@ cdef class CustomBusinessHour(BusinessHour): Normalize start/end dates to midnight before generating date range. weekmask : str, Default 'Mon Tue Wed Thu Fri' Weekmask of valid business days, passed to ``numpy.busdaycalendar``. - start : str, default "09:00" + start : str, time, or list of str/time, default "09:00" Start time of your custom business hour in 24h format. - end : str, default: "17:00" + end : str, time, or list of str/time, default: "17:00" End time of your custom business hour in 24h format. Examples From 25913f08343fef5f9797bb9c02c3a95bce082c57 Mon Sep 17 00:00:00 2001 From: Siddhartha Gandhi Date: Sat, 3 Dec 2022 18:12:43 -0500 Subject: [PATCH 2/2] Add additional examples to pd.offsets.BusinessHour and CustomBusinessHour This covers usage of datetime.time start/end values as well as multiple start and end values --- pandas/_libs/tslibs/offsets.pyx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 14dd2d93e0e68..6352ba0ac3275 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1622,9 +1622,17 @@ cdef class BusinessHour(BusinessMixin): Examples -------- + >>> from datetime import time >>> ts = pd.Timestamp(2022, 8, 5, 16) >>> ts + pd.offsets.BusinessHour() Timestamp('2022-08-08 09:00:00') + >>> ts + pd.offsets.BusinessHour(start="11:00") + Timestamp('2022-08-08 11:00:00') + >>> ts + pd.offsets.BusinessHour(end=time(19, 0)) + Timestamp('2022-08-05 17:00:00') + >>> ts + pd.offsets.BusinessHour(start=[time(9, 0), "20:00"], + ... end=["17:00", time(22, 0)]) + Timestamp('2022-08-05 20:00:00') """ _prefix = "BH" @@ -3626,9 +3634,17 @@ cdef class CustomBusinessHour(BusinessHour): Examples -------- + >>> from datetime import time >>> ts = pd.Timestamp(2022, 8, 5, 16) >>> ts + pd.offsets.CustomBusinessHour() Timestamp('2022-08-08 09:00:00') + >>> ts + pd.offsets.CustomBusinessHour(start="11:00") + Timestamp('2022-08-08 11:00:00') + >>> ts + pd.offsets.CustomBusinessHour(end=time(19, 0)) + Timestamp('2022-08-05 17:00:00') + >>> ts + pd.offsets.CustomBusinessHour(start=[time(9, 0), "20:00"], + ... end=["17:00", time(22, 0)]) + Timestamp('2022-08-05 20:00:00') """ _prefix = "CBH"