Skip to content

DOC: Add examples to frequency classes and methods #48011

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 9 commits into from
Aug 10, 2022

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Aug 9, 2022

The goal is to eventually enable the EX01 (all docstrings have examples), so adding simple examples to the public frequency classes and methods.

@mroeschke mroeschke added Docs Frequency DateOffsets labels Aug 9, 2022
@mroeschke mroeschke added this to the 1.5 milestone Aug 9, 2022
@@ -559,6 +607,20 @@ cdef class BaseOffset:

@cache_readonly
def freqstr(self) -> str:
"""
Return a string representing the frequency.
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this differ from the name? i.e. is there a diff between,

>>> pd.offsets.Hour(5).name  # which is "H" in above example
>>> pd.offsets.Hour(5).freqstr

?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIU: name is the "base" frequency unit (H), and freqstr is the entire frequency with its multiple (5H).

Added additional examples to name and freqstr to clarify this

dt : datetime.datetime
Timestamp to check intersections with frequency.

Examples
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we get an example where this is False as well. Think this might be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Added an example which returns False

@@ -745,26 +822,96 @@ cdef class BaseOffset:
def is_anchored(self) -> bool:
# TODO: Does this make sense for the general case? It would help
# if there were a canonical docstring for what is_anchored means.
"""
Return boolean whether the frequency is a unit frequency.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this - but I don't use these functions frequently.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a note here that unit means (n=1)

Copy link
Contributor

@attack68 attack68 left a comment

Choose a reason for hiding this comment

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

these all lgtm, didn't realise there were so many of these types of function actually. interesting :)

@mroeschke mroeschke merged commit 7c99031 into pandas-dev:main Aug 10, 2022
@mroeschke mroeschke deleted the doc/offsets/examples branch August 10, 2022 21:00
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
* Add examples to offsets

* Finish examples for offsets

* Finish examples for offsets

* Undo API removals, fix failures

* Address review
@asishm asishm mentioned this pull request Dec 19, 2022
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.

2 participants