Skip to content

Commit 1b23a7d

Browse files
authored
DOC: Update start/end parameter for BusinessHour and CustomBusinessHour (#49774)
* Update start/end parameter documentation for BusinessHour and CustomBusinessHour to mention allowed input types of time and list of str/time * 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
1 parent 7d2337a commit 1b23a7d

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,16 +1615,24 @@ cdef class BusinessHour(BusinessMixin):
16151615
Normalize start/end dates to midnight before generating date range.
16161616
weekmask : str, Default 'Mon Tue Wed Thu Fri'
16171617
Weekmask of valid business days, passed to ``numpy.busdaycalendar``.
1618-
start : str, default "09:00"
1618+
start : str, time, or list of str/time, default "09:00"
16191619
Start time of your custom business hour in 24h format.
1620-
end : str, default: "17:00"
1620+
end : str, time, or list of str/time, default: "17:00"
16211621
End time of your custom business hour in 24h format.
16221622
16231623
Examples
16241624
--------
1625+
>>> from datetime import time
16251626
>>> ts = pd.Timestamp(2022, 8, 5, 16)
16261627
>>> ts + pd.offsets.BusinessHour()
16271628
Timestamp('2022-08-08 09:00:00')
1629+
>>> ts + pd.offsets.BusinessHour(start="11:00")
1630+
Timestamp('2022-08-08 11:00:00')
1631+
>>> ts + pd.offsets.BusinessHour(end=time(19, 0))
1632+
Timestamp('2022-08-05 17:00:00')
1633+
>>> ts + pd.offsets.BusinessHour(start=[time(9, 0), "20:00"],
1634+
... end=["17:00", time(22, 0)])
1635+
Timestamp('2022-08-05 20:00:00')
16281636
"""
16291637

16301638
_prefix = "BH"
@@ -3619,16 +3627,24 @@ cdef class CustomBusinessHour(BusinessHour):
36193627
Normalize start/end dates to midnight before generating date range.
36203628
weekmask : str, Default 'Mon Tue Wed Thu Fri'
36213629
Weekmask of valid business days, passed to ``numpy.busdaycalendar``.
3622-
start : str, default "09:00"
3630+
start : str, time, or list of str/time, default "09:00"
36233631
Start time of your custom business hour in 24h format.
3624-
end : str, default: "17:00"
3632+
end : str, time, or list of str/time, default: "17:00"
36253633
End time of your custom business hour in 24h format.
36263634
36273635
Examples
36283636
--------
3637+
>>> from datetime import time
36293638
>>> ts = pd.Timestamp(2022, 8, 5, 16)
36303639
>>> ts + pd.offsets.CustomBusinessHour()
36313640
Timestamp('2022-08-08 09:00:00')
3641+
>>> ts + pd.offsets.CustomBusinessHour(start="11:00")
3642+
Timestamp('2022-08-08 11:00:00')
3643+
>>> ts + pd.offsets.CustomBusinessHour(end=time(19, 0))
3644+
Timestamp('2022-08-05 17:00:00')
3645+
>>> ts + pd.offsets.CustomBusinessHour(start=[time(9, 0), "20:00"],
3646+
... end=["17:00", time(22, 0)])
3647+
Timestamp('2022-08-05 20:00:00')
36323648
"""
36333649

36343650
_prefix = "CBH"

0 commit comments

Comments
 (0)