-
-
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
Conversation
pandas/core/indexes/datetimes.py
Outdated
|
||
Returns | ||
------- | ||
ndarray of integers indicating the day of the week |
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.
In case of Series.dt
it actually returns a Series of integers
|
||
See Also | ||
-------- | ||
pandas.Series.dt.dayofweek : Identical method. |
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.
See Also
--------
pandas.Series.dt.dayofweek : alias
pandas.Series.dt.weekday : alias
pandas.Series.dt.day_name :
Return the day names of the DateTimeIndex with specified locale.
Note that the docstring for dayofweek
and weekday
is the exact same.
dayofweek = _field_accessor('dayofweek', 'dow', _dayofweek_doc)
weekday = dayofweek
pandas/core/indexes/datetimes.py
Outdated
Series | ||
Containing integers indicating the week number. | ||
|
||
ndarray of integers indicating the day of the week |
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.
duplicate line
-------- | ||
>>> 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 comment
The reason will be displayed to describe this comment to others. Learn more.
we have a method day_name
for 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.
did not know this. i was confused because i saw weekday_name
but this was depricated. i've changed the code and added day_name
to the "see also" too.
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.
change the code here as well and simply use day_name
7 2017-01-07 5 Saturday | ||
8 2017-01-08 6 Sunday | ||
|
||
Note: `pandas.Series.dt.dayofweek`/`pandas.Series.dt.weekday` are the same. |
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 are operating on an Index here (and the doc-string goes for both)
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.
@jreback could you elaborate? im not sure what you mean with that.
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.
ignore my comment here
|
||
Returns | ||
------- | ||
ndarray |
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.
these return an Index
-------- | ||
>>> 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 comment
The reason will be displayed to describe this comment to others. Learn more.
change the code here as well and simply use day_name
7 2017-01-07 5 Saturday | ||
8 2017-01-08 6 Sunday | ||
|
||
Note: `pandas.Series.dt.dayofweek`/`pandas.Series.dt.weekday` are the same. |
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.
ignore my comment here
7 5 | ||
8 6 | ||
dtype: int64 | ||
>>> s.dt.weekday |
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 don't need to show both, just use dayofweek
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks: