Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bigframes/operations/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def dayofweek(self) -> series.Series:
def day_of_week(self) -> series.Series:
return self.dayofweek

@property
def weekday(self) -> series.Series:
return self.dayofweek

@property
def dayofyear(self) -> series.Series:
return self._data._apply_unary_op(ops.dayofyear_op)
Expand Down
15 changes: 15 additions & 0 deletions tests/system/small/operations/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ def test_dt_day_of_week(scalars_dfs, col_name):
assert_series_equal(pd_result, bf_result, check_dtype=False)


@pytest.mark.parametrize(
("col_name",),
DATE_COLUMNS,
)
def test_dt_weekday(scalars_dfs, col_name):
pytest.importorskip("pandas", minversion="2.0.0")
scalars_df, scalars_pandas_df = scalars_dfs
bf_series: bigframes.series.Series = scalars_df[col_name]

bf_result = bf_series.dt.weekday.to_pandas()
pd_result = scalars_pandas_df[col_name].dt.weekday

assert_series_equal(pd_result, bf_result, check_dtype=False)


@pytest.mark.parametrize(
("col_name",),
DATE_COLUMNS,
Expand Down
31 changes: 31 additions & 0 deletions third_party/bigframes_vendored/pandas/core/indexes/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,37 @@ def day_of_week(self):

raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

@property
def weekday(self):
"""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.

**Examples:**

>>> s = bpd.Series(
... pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
... )
>>> s.dt.weekday
2016-12-31 00:00:00 5
2017-01-01 00:00:00 6
2017-01-02 00:00:00 0
2017-01-03 00:00:00 1
2017-01-04 00:00:00 2
2017-01-05 00:00:00 3
2017-01-06 00:00:00 4
2017-01-07 00:00:00 5
2017-01-08 00:00:00 6
dtype: Int64

Returns:
Series: Containing integers indicating the day number.
"""

raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

@property
def day_name(self):
"""
Expand Down