Skip to content

DOC: Update start/end parameter for BusinessHour and CustomBusinessHour #49774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1615,16 +1615,24 @@ 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add to the Examples section showing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke Done

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 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"
Expand Down Expand Up @@ -3619,16 +3627,24 @@ 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 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"
Expand Down