Skip to content

Commit

Permalink
fix: fix grouping series on multiple other series (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorBergeron authored Mar 19, 2024
1 parent 85fefa2 commit 3971bd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ def _groupby_values(
get_column_right,
) = block.join(key._block, how="inner" if dropna else "left")

value_col = get_column_left[self._value_column]
value_col = get_column_left[value_col]
grouping_cols = [
*[get_column_left[value] for value in grouping_cols],
get_column_right[key._value_column],
Expand Down
10 changes: 8 additions & 2 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,9 +1313,15 @@ def test_any(scalars_dfs):
def test_groupby_sum(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
col_name = "int64_too"
bf_series = scalars_df[col_name].groupby(scalars_df["string_col"]).sum()
bf_series = (
scalars_df[col_name]
.groupby([scalars_df["bool_col"], ~scalars_df["bool_col"]])
.sum()
)
pd_series = (
scalars_pandas_df[col_name].groupby(scalars_pandas_df["string_col"]).sum()
scalars_pandas_df[col_name]
.groupby([scalars_pandas_df["bool_col"], ~scalars_pandas_df["bool_col"]])
.sum()
)
# TODO(swast): Update groupby to use index based on group by key(s).
bf_result = bf_series.to_pandas()
Expand Down

0 comments on commit 3971bd2

Please sign in to comment.