-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Fixed examples in pandas/tseries #32935
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
Changes from 2 commits
715ef4b
8cf1d90
95b70f7
d1c9d40
c32fbf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,15 +157,34 @@ class from pandas.tseries.offsets | |
-------- | ||
>>> from pandas.tseries.holiday import Holiday, nearest_workday | ||
>>> from dateutil.relativedelta import MO | ||
>>> USMemorialDay = Holiday('Memorial Day', month=5, day=31, | ||
offset=pd.DateOffset(weekday=MO(-1))) | ||
>>> USLaborDay = Holiday('Labor Day', month=9, day=1, | ||
offset=pd.DateOffset(weekday=MO(1))) | ||
>>> July3rd = Holiday('July 3rd', month=7, day=3,) | ||
>>> NewYears = Holiday('New Years Day', month=1, day=1, | ||
observance=nearest_workday), | ||
>>> July3rd = Holiday('July 3rd', month=7, day=3, | ||
days_of_week=(0, 1, 2, 3)) | ||
|
||
>>> USMemorialDay = Holiday( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does a code check complain about this without this change? this makes it harder to copy/paste an example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, flake8 complains that this line's length is larger than 88 characters. |
||
... "Memorial Day", month=5, day=31, offset=pd.DateOffset(weekday=MO(-1)) | ||
... ) | ||
>>> USMemorialDay | ||
Holiday: Memorial Day (month=5, day=31, offset=<DateOffset: weekday=MO(-1)>) | ||
|
||
>>> USLaborDay = Holiday( | ||
... "Labor Day", month=9, day=1, offset=pd.DateOffset(weekday=MO(1)) | ||
... ) | ||
>>> USLaborDay | ||
Holiday: Labor Day (month=9, day=1, offset=<DateOffset: weekday=MO(+1)>) | ||
|
||
>>> July3rd = Holiday("July 3rd", month=7, day=3) | ||
>>> July3rd | ||
Holiday: July 3rd (month=7, day=3, ) | ||
|
||
>>> NewYears = Holiday( | ||
... "New Years Day", month=1, day=1, observance=nearest_workday | ||
... ) | ||
>>> NewYears # doctest: +SKIP | ||
Holiday: New Years Day ( | ||
month=1, day=1, observance=<function nearest_workday at 0x66545e9bc440> | ||
) | ||
|
||
>>> July3rd = Holiday("July 3rd", month=7, day=3, days_of_week=(0, 1, 2, 3)) | ||
>>> July3rd | ||
Holiday: July 3rd (month=7, day=3, ) | ||
""" | ||
if offset is not None and observance is not None: | ||
raise NotImplementedError("Cannot use both offset and observance.") | ||
|
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.
timedelta is in the module namespace. instead of importing here, would this be fixed by changing
datetime.timedelta
on L110 to justtimedelta
?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.
pytest
is having a scope for each docstring, so in order to havetimedelta
instead ofdatetime.timedelta
, L98 would have to befrom datetime import timedelta
.Another option (which IMO is least preferred, is to import it below, at L109 for example)
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.
we always have
pd
in the namespace right? how aboutpd.Timedelta
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.
Worked!