Skip to content

Commit 7d23f9d

Browse files
committed
fix: correct index labels with multi-index DataFrameGroupBy
1 parent a76a403 commit 7d23f9d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bigframes/core/groupby/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,18 @@ def _agg_list(self, func: typing.Sequence) -> df.DataFrame:
339339
for col_id in self._aggregated_columns()
340340
for f in func
341341
]
342+
343+
aggregated_columns = pd.MultiIndex.from_tuples(
344+
[
345+
self._block.col_id_to_label[col_id]
346+
for col_id in self._aggregated_columns()
347+
],
348+
names=[*self._block.column_labels.names],
349+
).to_frame(index=False)
350+
342351
column_labels = [
343-
(self._block.col_id_to_label[col_id], f)
344-
for col_id in self._aggregated_columns()
352+
tuple(col_id) + (f,)
353+
for col_id in aggregated_columns.to_numpy()
345354
for f in func
346355
]
347356
agg_block, _ = self._block.aggregate(

0 commit comments

Comments
 (0)