-
-
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 5 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 |
---|---|---|
|
@@ -1707,7 +1707,64 @@ def freq(self, value): | |
nanosecond = _field_accessor('nanosecond', 'ns', | ||
"The nanoseconds of the datetime") | ||
weekofyear = _field_accessor('weekofyear', 'woy', | ||
"The week ordinal of the year") | ||
""" | ||
The week ordinal of the year. | ||
|
||
Return the week ordinal of the year. Note that there can be | ||
counter intuitive edge cases around the yearchange. For example | ||
the first of january could be in week 52 of the previous year. | ||
Monday indicates the start of a new week. | ||
|
||
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. | ||
|
||
Returns | ||
------- | ||
ndarray of formatted strings | ||
|
||
Examples | ||
-------- | ||
>>> dates = pd.date_range("2016-12-31", "2017-01-08", freq="D") | ||
>>> s = pd.Series(dates) | ||
>>> pd.DataFrame({'date':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. pep8: space after colons 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. oops. fixed in next commit. |
||
date 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 what `series.dt.week` and `series.dt.weekofyear` are the same. | ||
|
||
>>> 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 | ||
""") | ||
week = weekofyear | ||
dayofweek = _field_accessor('dayofweek', 'dow', | ||
"The day of the week with Monday=0, Sunday=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.
This is where
E128
is still complaining a bit. I don't know what the nicest way is to resolve this since we're a bit unconventional with the_field_accessor
accepting a docstring here. I could add tabs to the docstring, but it would make the code much less readable (as well cause ugly things to 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.
@TomAugspurger would love advice.
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.
@koaning maybe just make a new variable called
_weekofyear_doc
and assign it to likeThere 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.
you'll get a lot of variables in that file, but that works for me. will make the change. thanks!