Skip to content

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

Merged
merged 5 commits into from
Mar 27, 2020

Conversation

ShaharNaveh
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@@ -95,16 +95,18 @@ def to_offset(freq) -> Optional[DateOffset]:

Examples
--------
>>> to_offset('5min')
>>> import datetime
Copy link
Member

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 just timedelta?

Copy link
Member Author

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 have timedelta instead of datetime.timedelta, L98 would have to be from datetime import timedelta.

Another option (which IMO is least preferred, is to import it below, at L109 for example)

Copy link
Member

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 about pd.Timedelta

Copy link
Member Author

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 about pd.Timedelta

Worked!

>>> July3rd = Holiday('July 3rd', month=7, day=3,
days_of_week=(0, 1, 2, 3))

>>> USMemorialDay = Holiday(
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm

@WillAyd WillAyd added the Docs label Mar 25, 2020
@WillAyd WillAyd added this to the 1.1 milestone Mar 25, 2020
@WillAyd WillAyd merged commit 13b9e40 into pandas-dev:master Mar 27, 2020
@WillAyd
Copy link
Member

WillAyd commented Mar 27, 2020

Thanks @MomIsBestFriend

@ShaharNaveh ShaharNaveh deleted the DOC-doctest-pandas-tseries branch March 29, 2020 09:24
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.

3 participants