Skip to content

DOC : update the pandas.Period.weekday docstring #20413

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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,32 @@ cdef class _Period(object):

@property
def weekday(self):
"""
Get day of the week that a Period falls on.
Copy link
Member

Choose a reason for hiding this comment

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

As this is a property and not a function, no need to start with a verb, you can start with "Day of the week...".

Also, as Period here is the pandas object, you can use backticks to highlight it.

I think in the extended summary you could explain that 0 means Monday...


Returns
-------
int

See Also
--------
Period.dayofweek : Get the day component of the Period.
Copy link
Member

Choose a reason for hiding this comment

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

From the description, I can't see the difference between weekday and dayofweek. Can you clarify it please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup sure 👍

Period.week : Get the week of the year on the given Period.

Examples
--------
>>> p = pd.Period("2018-03-11", "H")
>>> p.weekday
6
Copy link
Member

Choose a reason for hiding this comment

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

I think the examples give the idea that a Period is a single day. I'd use a Period for a quarter that should make it clearer that this is not a single day.

And also, or here or in the summary, give more details on which day of the week of the 3 months period is being returned.


>>> p = pd.Period("2018-02-01", "D")
>>> p.weekday
3

>>> p = pd.Period("2018-01-06", "D")
>>> p.weekday
5
"""
return self.dayofweek

@property
Expand Down