8000 fix: fix grouping series on multiple other series by TrevorBergeron · Pull Request #455 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

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
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