-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Conversation
@@ -1613,9 +1613,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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mroeschke Done
22c69cf
to
4c0ffb9
Compare
pandas/_libs/tslibs/offsets.pyx
Outdated
>>> ts + pd.offsets.CustomBusinessHour(end=dt_time(19, 0)) | ||
Timestamp('2022-08-05 17:00:00') | ||
>>> ts + pd.offsets.CustomBusinessHour(start=[dt_time(9, 0), "20:00"], | ||
... end=["17:00", dt_time(22, 0)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstrings examples apparently get compiled. This is failing. I tried time
, but the error seemed to indicate it uses the same imports as the module itself - so I updated to using dt_time
, which still didn't work. Based on the following import:
from cpython.datetime cimport (
PyDate_Check,
PyDateTime_Check,
PyDelta_Check,
date,
datetime,
import_datetime,
time as dt_time,
timedelta,
)
I would have expected dt_time
to work. What's the right syntax here?
pandas/_libs/tslibs/offsets.pyx
Outdated
End time of your custom business hour in 24h format. | ||
|
||
Examples | ||
-------- | ||
>>> 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=dt_time(19, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to import dt_time
before the first usage.
>>> from datetime import time as dt_time
…usinessHour to mention allowed input types of time and list of str/time
…Hour This covers usage of datetime.time start/end values as well as multiple start and end values
Thanks @gandhis1 |
These are all valid usages. Examples from pandas-stubs here:
https://github.com/pandas-dev/pandas-stubs/blob/main/tests/test_timefuncs.py#L601-L639