-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
DOC : update the pandas.Period.weekday docstring #20413
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20413 +/- ##
==========================================
- Coverage 91.96% 91.8% -0.17%
==========================================
Files 166 152 -14
Lines 50331 49205 -1126
==========================================
- Hits 46289 45171 -1118
+ Misses 4042 4034 -8
Continue to review full report at Codecov.
|
pandas/_libs/tslibs/period.pyx
Outdated
@@ -1416,6 +1416,32 @@ cdef class _Period(object): | |||
|
|||
@property | |||
def weekday(self): | |||
""" | |||
Get day of the week that a Period falls on. |
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.
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
...
pandas/_libs/tslibs/period.pyx
Outdated
|
||
See Also | ||
-------- | ||
Period.dayofweek : Get the day component of the Period. |
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.
From the description, I can't see the difference between weekday
and dayofweek
. Can you clarify it please?
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.
yup sure 👍
pandas/_libs/tslibs/period.pyx
Outdated
-------- | ||
>>> p = pd.Period("2018-03-11", "H") | ||
>>> p.weekday | ||
6 |
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.
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.
@jbrockmendel do you mind reviewing this docstring? (both are the same, we can't reuse in this case) |
pandas/_libs/tslibs/period.pyx
Outdated
>>> period2 | ||
Period('2013-01-09 11:00', 'H') | ||
>>> period2.dayofweek | ||
For periods with a frequancy higher than days, the last day of the |
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.
typo frequency
pandas/_libs/tslibs/period.pyx
Outdated
>>> per.start_time.dayofweek | ||
6 | ||
|
||
For periods with a frequancy higher than days, the last day of the |
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.
typo frequency
""" | ||
# Docstring is a duplicate from dayofweek. Reusing docstrings with | ||
# Appender doesn't work for properties in Cython files, and setting | ||
# the __doc__ attribute is also not possible. |
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.
Would it work using syntax to the effect of weekday = property(dayofweek.fget, doc=dayofweek.__doc__)
?
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.
Thanks for the feedback. That's actually a great idea, didn't know property had an argument for the doc. Unfortunately this doesn't seem to be supported in cython:
weekday = property(dayofweek.fget, doc=dayofweek.__doc__)
^
------------------------------------------------------------
pandas/_libs/tslibs/period.pyx:1430:23: 'dayofweek' is not a constant, variable or function identifier
Pending typo fixups, LGTM. |
Thanks @IHackPy for the PR, and thanks @jbrockmendel for the reviews. |
Thanks Marc ! and sorry I forget to complete some string I thought . I will
update soon.
…On Wed, Jul 18, 2018 at 3:23 PM, Marc Garcia ***@***.***> wrote:
Thanks @IHackPy <https://github.com/IHackPy> for the PR, and thanks
@jbrockmendel <https://github.com/jbrockmendel> for the reviews.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20413 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AV3rxUjxkNSmABFkgy8Ls3fZiDOhnRYiks5uHwWagaJpZM4SwtDn>
.
--
Thanks and Regards
Himanshu Awasthi,
Freelancer & Enthusiastic Engineering Student
KanpurFOSS Community
+91 7310476826 |Twitter @IHackPy <https://twitter.com/IHackPY>
|
Period.weekday
################################################################################
###################### Docstring (pandas.Period.weekday) ######################
################################################################################
Get day of the week that a Period falls on.
Returns
int
See Also
Period.dayofweek : Get the day component of the Period.
Period.week : Get the week of the year on the given Period.
Examples
################################################################################
################################## Validation ##################################
################################################################################