Skip to content

DOC: add examples to offsets CustomBusinessDay, Business/MonthBegin #51932

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 3 commits into from
Mar 15, 2023

Conversation

natmokval
Copy link
Contributor

This pr is related to pr #50182, #49958 and #50027.

Updated docs for BusinessMonthBegin, CustomBusinessDay and MonthBegin. Added more examples to highlight “the first day of the month” behavior. Gave examples that use the parameter n equals 0. Provided more examples for CustomBusinessDay parameters weekmask and calendar.

@mroeschke mroeschke added Docs Frequency DateOffsets labels Mar 13, 2023
@natmokval
Copy link
Contributor Author

Hi @MarcoGorelli. I updated documentation for CustomBusinessDay, BusinessMonthBegin and MonthBegin. Corrected lists of parameters and provided more examples.
Could you, please, take a look at this PR?

@natmokval natmokval marked this pull request as ready for review March 13, 2023 18:20
@MarcoGorelli MarcoGorelli self-requested a review March 13, 2023 18:24
@datapythonista
Copy link
Member

/preview

@github-actions
Copy link
Contributor

Website preview of this PR available at: https://pandas.pydata.org/preview/51932/

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice, thanks for working on this!

Just got a comment on offset


Website preview of this PR available at: https://pandas.pydata.org/preview/51932/

😱 wow, nice!

@@ -3688,13 +3717,38 @@ cdef class CustomBusinessDay(BusinessDay):
List/array of dates to exclude from the set of valid business days,
passed to ``numpy.busdaycalendar``.
calendar : np.busdaycalendar
offset : timedelta, default timedelta(0)
Copy link
Member

Choose a reason for hiding this comment

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

why remove offset? I think it works, e.g.

In [18]: pd.Timestamp(2022, 8, 5, 16) + pd.offsets.CustomBusinessDay(1)
Out[18]: Timestamp('2022-08-08 16:00:00')

In [19]: pd.Timestamp(2022, 8, 5, 16) + pd.offsets.CustomBusinessDay(1, offset=timedelta(days=1))
Out[19]: Timestamp('2022-08-09 16:00:00')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the comment. It was my mistake, I thought offset doesn’t have an effect on CustomBusinessDay. I corrected the list of parameters and add an example for offset.

I noticed, that we don't have offset in the list of parameters in BusinessDay. Maybe it would be good to add it?

Copy link
Member

Choose a reason for hiding this comment

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

yup, sounds good, thanks for checking!

@natmokval
Copy link
Contributor Author

natmokval commented Mar 15, 2023

Looks like ci failures are related to my new example for offset.

D:\a\pandas\pandas\pandas\_libs\tslibs\src\datetime\np_datetime.c : fatal error C1083: Cannot open compiler generated file: 'D:\a\pandas\pandas\build\temp.win-amd64-cpython-39\Release\pandas\_libs\tslibs\src\datetime\np_datetime.obj': Permission denied

link

I use Linux and can’t catch errors raised for windows platform.

There is a Timedelta function in pandas, which shifts days as well and I can use this one.
pd.Timestamp(2022, 8, 5, 16) + pd.offsets.CustomBusinessDay(1, offset=pd.Timedelta(days=1))
Will it work for windows?

@natmokval
Copy link
Contributor Author

Website preview of this PR available at: https://pandas.pydata.org/preview/51932/

Nice, thank you!

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Really nice, this makes it so much easier to use, thanks @natmokval !

@MarcoGorelli
Copy link
Member

Looks like ci failures are related to my new example for offset.

it's unrelated, it happens before even having finished compiling pandas (which isn't affected by docstrings)

@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Mar 15, 2023
@MarcoGorelli MarcoGorelli merged commit e9a2eb8 into pandas-dev:main Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants