Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit fafd7c7

Browse filesBrowse files
authored
feat: add 'weekday' property to DatatimeMethod (#2304)
Fixes b/464971054 🦕
1 parent 37c685d commit fafd7c7
Copy full SHA for fafd7c7

3 files changed

+50Lines changed: 50 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bigframes/operations/datetimes.py‎

Copy file name to clipboardExpand all lines: bigframes/operations/datetimes.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def dayofweek(self) -> series.Series:
5454
def day_of_week(self) -> series.Series:
5555
return self.dayofweek
5656

57+
@property
58+
def weekday(self) -> series.Series:
59+
return self.dayofweek
60+
5761
@property
5862
def dayofyear(self) -> series.Series:
5963
return self._data._apply_unary_op(ops.dayofyear_op)
Collapse file

‎tests/system/small/operations/test_datetimes.py‎

Copy file name to clipboardExpand all lines: tests/system/small/operations/test_datetimes.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ def test_dt_day_of_week(scalars_dfs, col_name):
108108
assert_series_equal(pd_result, bf_result, check_dtype=False)
109109

110110

111+
@pytest.mark.parametrize(
112+
("col_name",),
113+
DATE_COLUMNS,
114+
)
115+
def test_dt_weekday(scalars_dfs, col_name):
116+
pytest.importorskip("pandas", minversion="2.0.0")
117+
scalars_df, scalars_pandas_df = scalars_dfs
118+
bf_series: bigframes.series.Series = scalars_df[col_name]
119+
120+
bf_result = bf_series.dt.weekday.to_pandas()
121+
pd_result = scalars_pandas_df[col_name].dt.weekday
122+
123+
assert_series_equal(pd_result, bf_result, check_dtype=False)
124+
125+
111126
@pytest.mark.parametrize(
112127
("col_name",),
113128
DATE_COLUMNS,
Collapse file

‎third_party/bigframes_vendored/pandas/core/indexes/accessor.py‎

Copy file name to clipboardExpand all lines: third_party/bigframes_vendored/pandas/core/indexes/accessor.py
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,37 @@ def day_of_week(self):
9191

9292
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
9393

94+
@property
95+
def weekday(self):
96+
"""The day of the week with Monday=0, Sunday=6.
97+
98+
Return the day of the week. It is assumed the week starts on
99+
Monday, which is denoted by 0 and ends on Sunday, which is denoted
100+
by 6.
101+
102+
**Examples:**
103+
104+
>>> s = bpd.Series(
105+
... pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
106+
... )
107+
>>> s.dt.weekday
108+
2016-12-31 00:00:00 5
109+
2017-01-01 00:00:00 6
110+
2017-01-02 00:00:00 0
111+
2017-01-03 00:00:00 1
112+
2017-01-04 00:00:00 2
113+
2017-01-05 00:00:00 3
114+
2017-01-06 00:00:00 4
115+
2017-01-07 00:00:00 5
116+
2017-01-08 00:00:00 6
117+
dtype: Int64
118+
119+
Returns:
120+
Series: Containing integers indicating the day number.
121+
"""
122+
123+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
124+
94125
@property
95126
def day_name(self):
96127
"""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.