Skip to content

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

Merged
merged 7 commits into from
Jul 15, 2025
Merged

Conversation

sycai
Copy link
Contributor

@sycai sycai commented Jul 15, 2025

Fixes #432038604

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Jul 15, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jul 15, 2025
@sycai sycai requested review from GarrettWu and chelsea-lin July 15, 2025 21:05
@sycai sycai marked this pull request as ready for review July 15, 2025 21:05
@sycai sycai requested review from a team as code owners July 15, 2025 21:05
>>> s = bpd.Series(
... pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
... )
>>> s.dt.dayofweek
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@sycai sycai requested review from chelsea-lin and GarrettWu July 15, 2025 21:25
@sycai sycai merged commit 40e7638 into main Jul 15, 2025
20 of 25 checks passed
@sycai sycai deleted the sycai_dt branch July 15, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants