-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the pandas.Series.dt.dayofweek docstring #20230
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 2 commits
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,8 +1707,65 @@ def freq(self, value): | |
weekofyear = _field_accessor('weekofyear', 'woy', | ||
"The week ordinal of the year") | ||
week = weekofyear | ||
dayofweek = _field_accessor('dayofweek', 'dow', | ||
"The day of the week with Monday=0, Sunday=6") | ||
_dayofweek_doc = """ | ||
The day of the week with Monday=0, Sunday=6. | ||
|
||
Return the day of the week. It is assumed the week starts on | ||
Monday, which is denoted by 0 and ends on Sunday which is denoted | ||
by 6. | ||
|
||
See Also | ||
-------- | ||
pandas.Series.dt.dayofweek : Identical method. | ||
pandas.Series.dt.weekday : Identical method. | ||
|
||
Returns | ||
------- | ||
ndarray of integers indicating the day of the week | ||
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. In case of 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. duplicate line |
||
|
||
Examples | ||
-------- | ||
>>> dates = pd.date_range("2016-12-31", "2017-01-08", freq="D") | ||
>>> s = pd.Series(dates) | ||
>>> day_name = 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. we have a method 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. did not know this. i was confused because i saw 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. change the code here as well and simply use |
||
>>> pd.DataFrame({'dt': s, 'num': s.dt.weekday, 'day': day_name}) | ||
dt num day | ||
0 2016-12-31 5 Saturday | ||
1 2017-01-01 6 Sunday | ||
2 2017-01-02 0 Monday | ||
3 2017-01-03 1 Tuesday | ||
4 2017-01-04 2 Wednesday | ||
5 2017-01-05 3 Thursday | ||
6 2017-01-06 4 Friday | ||
7 2017-01-07 5 Saturday | ||
8 2017-01-08 6 Sunday | ||
|
||
Note that `series.dt.dayofweek` and `series.dt.weekday` are the same. | ||
|
||
>>> s.dt.dayofweek | ||
0 5 | ||
1 6 | ||
2 0 | ||
3 1 | ||
4 2 | ||
5 3 | ||
6 4 | ||
7 5 | ||
8 6 | ||
dtype: int64 | ||
>>> s.dt.weekday | ||
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 show both, just use dayofweek |
||
0 5 | ||
1 6 | ||
2 0 | ||
3 1 | ||
4 2 | ||
5 3 | ||
6 4 | ||
7 5 | ||
8 6 | ||
dtype: int64 | ||
""" | ||
dayofweek = _field_accessor('dayofweek', 'dow', _dayofweek_doc) | ||
weekday = dayofweek | ||
|
||
weekday_name = _field_accessor( | ||
|
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.
you can say alias
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.
add day_name as well
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've changed it into this now.
Note that the docstring for
dayofweek
andweekday
is the exact same.