Skip to content

Commit b102b1a

Browse files
fix tests
1 parent 1cf6432 commit b102b1a

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

bigframes/operations/datetimes.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from bigframes import dataframe, dtypes, series
2525
from bigframes.core import log_adapter
26-
from bigframes.core.reshape import concat
2726
import bigframes.operations as ops
2827
import bigframes.operations.base
2928

@@ -79,13 +78,12 @@ def month(self) -> series.Series:
7978
return self._apply_unary_op(ops.month_op)
8079

8180
def isocalendar(self) -> dataframe.DataFrame:
82-
years = self._apply_unary_op(ops.iso_year_op)
83-
weeks = self._apply_unary_op(ops.iso_week_op)
84-
days = self._apply_unary_op(ops.iso_day_op)
85-
86-
result = concat.concat([years, weeks, days], axis=1)
87-
result.columns = pandas.Index(["year", "week", "day"])
88-
return result
81+
iso_ops = [ops.iso_year_op, ops.iso_week_op, ops.iso_day_op]
82+
labels = pandas.Index(["year", "week", "day"])
83+
block = self._block.project_exprs(
84+
[op.as_expr(self._value_column) for op in iso_ops], labels, drop=True
85+
)
86+
return dataframe.DataFrame(block)
8987

9088
# Time accessors
9189
@property

tests/system/small/operations/test_dates.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ def test_date_series_diff_agg(scalars_dfs):
7676
def test_date_can_cast_after_accessor(scalars_dfs):
7777
bf_df, pd_df = scalars_dfs
7878

79-
actual_result = bf_df.date_col.dt.isocalendar().week.astype("Int64").to_pandas()
80-
expected_result = pd_df.date_col.dt.isocalendar().week.astype("Int64")
79+
actual_result = bf_df["date_col"].dt.isocalendar().week.astype("Int64").to_pandas()
80+
# convert to pd date type rather than arrow, as pandas doesn't handle arrow date well here
81+
expected_result = (
82+
pd.to_datetime(pd_df["date_col"]).dt.isocalendar().week.astype("Int64")
83+
)
8184

8285
pandas.testing.assert_series_equal(
8386
actual_result, expected_result, check_dtype=False, check_index_type=False

tests/system/small/operations/test_datetimes.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,3 @@ def test_to_datetime(scalars_dfs, col):
603603
testing.assert_series_equal(
604604
actual_result, expected_result, check_dtype=False, check_index_type=False
605605
)
606-
607-
608-
def test_timedelta_can_cast_after_dt_accessor(timedelta_series):
609-
bf_s, pd_s = timedelta_series
610-
611-
actual_result = bf_s.dt.isocalendar().week.astype("Int64").to_pandas()
612-
expected_result = pd_s.dt.isocalendar().week.astype("Int64")
613-
614-
assert_series_equal(
615-
actual_result, expected_result, check_dtype=False, check_index_type=False
616-
)

0 commit comments

Comments
 (0)