Skip to content

DOC: Update the Period.day docstring #20294

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 2 commits into from
Mar 12, 2018
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 @@ -1217,6 +1217,32 @@ cdef class _Period(object):

@property
def day(self):
"""
Return the number of days of particular month of a given Period.
Copy link
Member

Choose a reason for hiding this comment

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

This description would make me think this gives the number of days of the month the period falls in, i.e. if the month was February it would return 28. That's obviously note the case - can you think of a way to reword and make clearer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure I try to make this more clear I'm still thinking that summary is not good sense .
I have query : if we give any period like 2018-03-28 it return 28 so how i explain because I think it count all days till given date ?
If I think wrong correct me :)

Copy link
Member

Choose a reason for hiding this comment

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

I would say "Get day of the month that a Period falls on"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find better sort explanation as you mention on above comment


This attribute returns the total number of days of given month on which
Copy link
Member

Choose a reason for hiding this comment

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

This is a pretty simple function so depending on how concise the short summary is might be OK to not have an extended summary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but I think when I remove extended summary validation_docstring.py gives error ???

Copy link
Member

Choose a reason for hiding this comment

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

You are right that the script would fail but I think this would pass as an exception

the particular date occurs.

Returns
-------
Int
Copy link
Member

Choose a reason for hiding this comment

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

lowercase this

Number of days till particular date
Copy link
Member

Choose a reason for hiding this comment

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

This should be indented. Might want to reword based off of what you do with short summary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

still have confusion ?

Copy link
Member

Choose a reason for hiding this comment

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

Take a look at the contributing guide for the sprint. The very first example should show you how to format the Returns section

https://python-sprints.github.io/pandas/guide/pandas_docstring.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can I write :
int
day of that month

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or day of given month

Copy link
Member

Choose a reason for hiding this comment

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

Just write int here - this is simple enough that you don't need a description

For future reference though when you do put a description on the line below the type it needs to be indented (i.e. 4 spaces ahead of the line above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure


See also
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize Also

--------
Period.dayofweek
Return the day of the week
Copy link
Member

Choose a reason for hiding this comment

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

In this section the description should be on the same line as the referenced item separated by a " : "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mean ===>>>>(Period.dayofweek: Return the day of the week)

Copy link
Member

Choose a reason for hiding this comment

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

Put a space before the colon and change the word "Return" to "Get" and yes you are correct


Period.dayofyear
Return the day of the year

Examples
--------
>>> import pandas as pd
Copy link
Member

Choose a reason for hiding this comment

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

No need for import pandas as pd for any docstrings as it is implied (nor import numpy as np)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry my mistake

>>> p = pd.Period("2018-03-11", freq='H')
>>> p.day
11
"""
base, mult = get_freq_code(self.freq)
return pday(self.ordinal, base)

Expand Down