Skip to content

Commit

Permalink
feat: allow *arg syntax with GroupedTable methods
Browse files Browse the repository at this point in the history
this brings it in line with the normal Table methods
  • Loading branch information
NickCrews committed Apr 10, 2024
1 parent 2648498 commit 4870330
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ibis/expr/types/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def __getattr__(self, attr):
else:
return GroupedArray(field, self)

def aggregate(self, metrics=(), **kwds) -> ir.Table:
def aggregate(self, *metrics, **kwds) -> ir.Table:
"""Compute aggregates over a group by."""
return self.table.to_expr().aggregate(
metrics, by=self.groupings, having=self.havings, **kwds
)

agg = aggregate

def having(self, expr: ir.BooleanScalar) -> GroupedTable:
def having(self, *expr: ir.BooleanScalar) -> GroupedTable:
"""Add a post-aggregation result filter `expr`.
::: {.callout-warning}
Expand All @@ -92,7 +92,7 @@ def having(self, expr: ir.BooleanScalar) -> GroupedTable:
havings = tuple(bind(table, expr))
return self.copy(havings=self.havings + havings)

def order_by(self, expr: ir.Value | Iterable[ir.Value]) -> GroupedTable:
def order_by(self, *expr: ir.Value | Iterable[ir.Value]) -> GroupedTable:
"""Sort a grouped table expression by `expr`.
Notes
Expand Down Expand Up @@ -261,7 +261,7 @@ def count(self) -> ir.Table:
The aggregated table
"""
table = self.table.to_expr()
return table.aggregate([table.count()], by=self.groupings, having=self.havings)
return table.aggregate(table.count(), by=self.groupings, having=self.havings)

size = count

Expand Down

0 comments on commit 4870330

Please sign in to comment.