-
Notifications
You must be signed in to change notification settings - Fork 51
feat: provide day_of_year and day_of_week for dt accessor #1911
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
>>> s = bpd.Series( | ||
... pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series() | ||
... ) | ||
>>> s.dt.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.
s.dt.day_of_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.
Good catch!
>>> s = bpd.Series( | ||
... pd.date_range('2016-12-28', '2017-01-03', freq='D').to_series() | ||
... ) | ||
>>> s.dt.dayofyear |
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.
s.dt.day_of_year
instead?
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.
pandas uses the same example https://pandas.pydata.org/docs/dev/reference/api/pandas.Series.dt.day_of_week.html
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.
Done
@@ -66,6 +66,40 @@ def dayofweek(self): | |||
|
|||
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) | |||
|
|||
@property | |||
def day_of_week(self): | |||
"""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.
Is it possible to set __doc__ to avoid duplication?
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.
Like Chelsea just pointed out, there are some minor differences between docs so I think this is no longer feasible.
Fixes #432038604