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

Conversation

IHackPy
Copy link
Contributor

@IHackPy IHackPy commented Mar 19, 2018

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

p = pd.Period("2018-03-11", "H")
p.weekday
6

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

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

################################################################################
################################## Validation ##################################
################################################################################

@codecov
Copy link

codecov bot commented Mar 19, 2018

Codecov Report

Merging #20413 into master will decrease coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.18% <ø> (-0.18%) ⬇️
#single 41.85% <ø> (-0.38%) ⬇️
Impacted Files Coverage Δ
pandas/io/s3.py 72.72% <0%> (-13.64%) ⬇️
pandas/util/_doctools.py 0% <0%> (-12.88%) ⬇️
pandas/core/arrays/base.py 80.64% <0%> (-7.22%) ⬇️
pandas/io/formats/terminal.py 16.43% <0%> (-4.55%) ⬇️
pandas/io/formats/printing.py 89.38% <0%> (-3.71%) ⬇️
pandas/core/dtypes/missing.py 91.07% <0%> (-2.5%) ⬇️
pandas/io/common.py 68.77% <0%> (-1.88%) ⬇️
pandas/util/testing.py 83.95% <0%> (-1.74%) ⬇️
pandas/core/reshape/tile.py 93.37% <0%> (-1.37%) ⬇️
pandas/core/indexes/interval.py 93.08% <0%> (-1.23%) ⬇️
... and 91 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce87d06...fcaaf4b. Read the comment docs.

@jreback jreback added Docs Period Period data type labels Mar 19, 2018
@@ -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...


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 👍

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

@datapythonista
Copy link
Member

@jbrockmendel do you mind reviewing this docstring? (both are the same, we can't reuse in this case)

>>> period2
Period('2013-01-09 11:00', 'H')
>>> period2.dayofweek
For periods with a frequancy higher than days, the last day of the
Copy link
Member

Choose a reason for hiding this comment

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

typo frequency

>>> per.start_time.dayofweek
6

For periods with a frequancy higher than days, the last day of the
Copy link
Member

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.
Copy link
Member

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__)?

Copy link
Member

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

@jbrockmendel
Copy link
Member

jbrockmendel commented Jul 10, 2018

Pending typo fixups, LGTM.

@datapythonista datapythonista merged commit 1ce2473 into pandas-dev:master Jul 18, 2018
@datapythonista
Copy link
Member

Thanks @IHackPy for the PR, and thanks @jbrockmendel for the reviews.

@IHackPy
Copy link
Contributor Author

IHackPy commented Jul 19, 2018 via email

aeltanawy pushed a commit to aeltanawy/pandas that referenced this pull request Jul 20, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants