-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the series.dt.weekofyear docstring #20218
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
Changes from 8 commits
4916ea2
d2b5498
dfd26b3
f461492
83e03e2
aac1423
b5ca86b
d26938d
035f1c5
ec04a59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1706,9 +1706,67 @@ def freq(self, value): | |
"The microseconds of the datetime") | ||
nanosecond = _field_accessor('nanosecond', 'ns', | ||
"The nanoseconds of the datetime") | ||
weekofyear = _field_accessor('weekofyear', 'woy', | ||
"The week ordinal of the year") | ||
_weekofyear_doc = """ | ||
The week ordinal of the year. | ||
|
||
Return the week ordinal of the year. Note that there can be | ||
counter intuitive edge cases around a year change. For example | ||
the first of january could be in week 52 of the previous year. | ||
Monday indicates the start of a new week. | ||
|
||
Returns | ||
------- | ||
ndarray of integers indicating the week number | ||
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. I thikn
ndarray is the type, the rest is the ddescription. 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. Just to confirm, what you're suggesting is different than the docstring guide for the sprint.
example found here: https://python-sprints.github.io/pandas/guide/pandas_docstring.html |
||
|
||
See Also | ||
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. I think Returns goes before See Also 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. well spotted. fixed. |
||
-------- | ||
pandas.Series.dt.week : Identical method. | ||
pandas.Series.dt.weekofyear : Identical method. | ||
|
||
Examples | ||
-------- | ||
>>> dates = pd.date_range("2016-12-31", "2017-01-08", freq="D") | ||
>>> s = pd.Series(dates) | ||
>>> pd.DataFrame({'dt': s, 'week': s.dt.week, 'day': s.dt.strftime("%A")}) | ||
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. use |
||
dt week day | ||
0 2016-12-31 52 Saturday | ||
1 2017-01-01 52 Sunday | ||
2 2017-01-02 1 Monday | ||
3 2017-01-03 1 Tuesday | ||
4 2017-01-04 1 Wednesday | ||
5 2017-01-05 1 Thursday | ||
6 2017-01-06 1 Friday | ||
7 2017-01-07 1 Saturday | ||
8 2017-01-08 1 Sunday | ||
|
||
Note that `series.dt.week` and `series.dt.weekofyear` are the same. | ||
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. series -> Series 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. done. |
||
|
||
>>> s.dt.week | ||
0 52 | ||
1 52 | ||
2 1 | ||
3 1 | ||
4 1 | ||
5 1 | ||
6 1 | ||
7 1 | ||
8 1 | ||
dtype: int64 | ||
>>> s.dt.weekofyear | ||
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. you don't need to repeat them, use weekofyear one |
||
0 52 | ||
1 52 | ||
2 1 | ||
3 1 | ||
4 1 | ||
5 1 | ||
6 1 | ||
7 1 | ||
8 1 | ||
dtype: int64 | ||
""" | ||
weekofyear = _field_accessor('weekofyear', 'woy', _weekofyear_doc) | ||
week = weekofyear | ||
|
||
dayofweek = _field_accessor('dayofweek', 'dow', | ||
"The day of the week with Monday=0, Sunday=6") | ||
weekday = dayofweek | ||
|
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.
Ah sorry could you add a trailing backslash to the end of this line? Then we don't have a blank line at the start of the docstring.
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.
When I do that the validation script gives an error.
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.
Ah, nvm you're good then.