-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: updated documentation for BusinessHour and BusinessDay #50240
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
DOC: updated documentation for BusinessHour and BusinessDay #50240
Conversation
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.
Thanks for working on this @natmokval ! Got some minor comments, but overall this is a nice improvement
pandas/_libs/tslibs/offsets.pyx
Outdated
start : str, time, or list of str/time, default "09:00" | ||
Start time of your custom business hour in 24h format. | ||
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 | ||
You can use the parameter ``n`` to represent the shift to n hours. |
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.
perhaps "to represent a shift of n hours" would be clearer? likewise for above
pandas/_libs/tslibs/offsets.pyx
Outdated
>>> ts + pd.offsets.BusinessHour(end=dt_time(19, 0)) | ||
Timestamp('2022-08-08 10:00:00') | ||
|
||
The parameter ``normalize`` equal True forces shift to midnight. |
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.
I think it's clearer how you wrote it above
Passing the parameter ``normalize`` equal True, you shift the start
of next business hour to midnight.
Thank you @MarcoGorelli, I like doing it. I find the idea of slightly improving the documentation of offsets reasonable. Agreed, I did copy-and-paste this example from CustomBusinessHour. The PR is updated as you suggested. |
pandas/_libs/tslibs/offsets.pyx
Outdated
You can divide your business day hours into several parts. | ||
|
||
>>> import datetime as dt | ||
>>> freq = pd.offsets.CustomBusinessHour(start=["06:00", "10:00", "15: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.
I guess this should still be BusinessHour
? Sorry, I meant "copy-and-paste but still change the offset", I should've clarified
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.
Oops! I corrected my mistake. The copy-and-paste method can be dangerous sometimes.
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.
Nice - CI failures are unrelated and should be resolved now, I've just made some final suggestions - if you address them and add a commit then CI should hopefully be green
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.
Almost there 💪
There's some CI failures from the docstring validation script, check https://github.com/pandas-dev/pandas/actions/runs/3707564825/jobs/6284132896
pandas/_libs/tslibs/offsets.pyx
Outdated
Passing the parameter ``normalize`` equal True, you shift the start | ||
of next business day to midnight. |
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.
equal True -> equal to True
of next business day -> of the next business day
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.
I corrected my grammar mistakes and updated my PR.
pandas/_libs/tslibs/offsets.pyx
Outdated
Passing the parameter ``normalize`` equal True, you shift the start | ||
of next business hour to midnight. |
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.
same comment as above
Thank you MarcoGorelli, for your help. I checked the errors raised by the docstring validation script in CI and fixed them. It's interesting, why if I run the docstring validation script locally these errors don't occur. |
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.
Looks good to me, nice improvement, thanks @natmokval !
My guess is that you hadn't re-compiled your C extensions ( |
…dev#50240) * DOC: add examples to BusinessHour and BusinessDay I * DOC: add examples to BusinessHour and BusinessDay II * DOC: add examples to BusinessHour and BusinessDay III * DOC: add examples to BusinessHour and BusinessDay IV * DOC: add examples to BusinessHour and BusinessDay V * fixup! DOC: add examples to BusinessHour and BusinessDay V
Thank you MarcoGorelli, for your comment. Usually, I run On the other hand, when I tried to reproduce my mistake, I run |
if you just do |
This PR is related to PR #50182.
Updated documentation for
BusinessDay
,BusinessHour
,CustomBusinessHour
. Corrected lists of parameters and provided more examples.Could you, please, @MarcoGorelli, review my PR?