Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): allow *arg syntax with GroupedTable methods #8923

Merged
merged 1 commit into from
Apr 11, 2024
Merged
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
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
Loading