-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the Period.dayofyear docstring #20277
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
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1255,6 +1255,36 @@ cdef class _Period(object): | |
|
||
@property | ||
def dayofyear(self): | ||
""" | ||
Return the day of the year. | ||
|
||
This attribute returns the day of the year on which the particular | ||
date occurs. The return value ranges between 1 to 365 for regular | ||
years and 1 to 366 for leap years. | ||
|
||
Returns | ||
------- | ||
int | ||
The day of year. | ||
|
||
See Also | ||
-------- | ||
Period.dayofweek : Return the day of week. | ||
Period.daysinmonth : Return the days in that month. | ||
PeriodIndex.dayofyear : Return the day of year of all indexes. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add PeriodIndex.dayofyear There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean 'weekofyear' ? (dayofyear is the current docstring) |
||
Examples | ||
-------- | ||
>>> period = pd.Period("2015-10-23", freq='H') | ||
>>> period.dayofyear | ||
296 | ||
>>> period = pd.Period("2012-12-31", freq='D') | ||
>>> period.dayofyear | ||
366 | ||
>>> period = pd.Period("2013-01-01", freq='D') | ||
>>> period.dayofyear | ||
1 | ||
""" | ||
base, mult = get_freq_code(self.freq) | ||
return pday_of_year(self.ordinal, base) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Periods represent time spans so it's good to note that this is the start of the period. So maybe
That's a bit wordy though. Feel free to reword if you have a better phrasing.
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.
sorry, but I didn't understand the meaning of the sentence
Return the day of the year the of the Period's start.
, specifically of theperiod's start
Uh oh!
There was an error while loading. Please reload this page.
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.
Period is a span, so saying "Day of the year" is a bit ambiguous. Is it the start, end, somewhere in between?
If you have a period like `Period('2017-01-01', freq='A')
I was apparently wrong about it always being the start. I guess it's related to
freq
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.
This comment will be relevant to many of the Period attributes like day, dayofyear, .. (also the ones I already merged ..).
So it would be good to be consistent in it.
The annual frequency is by default a "year-end" frequency, so it's indeed freq related.
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'm sorry, I don't follow... Can you show two cases creating a period starting on the same day but with different frequencies, and how this affect
.day
,.dayofweek
,.dayofyear
, etc.?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.
@dukebody small example:
I am not really familiar with this frequency business, but you have certain frequences which are "anchored" at the beginning of the period, and others at the end of the period. But I don't directly see a way how to inspect this.
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.
That's quite confusing. Should we open a ticket to make
.dayofyear
etc. always refer to the start time of the period? Not to the "anchored" time. Otherwise these functions are very unpredictable IMO and therefore don't add a lot of value.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.
Yes, I am writing one currently ;)
I suppose those attributes will mainly be useful for frequencies <= 1D
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'm OK with merging this PR without referring to the start or end date of the period, and then work on code to make this predictable and change all docstrings to refer to the period start date.