>>> import ibis
>>> import ibis.selectors as s
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> tGroupedTable
GroupedTable(**kwargs)An intermediate table expression to hold grouping information.
Methods
| Name | Description |
|---|---|
| aggregate | Compute aggregates over a group by. |
| count | Computing the number of rows per group. |
| having | Add a post-aggregation result filter expr. |
| mutate | Return a table projection with window functions applied. |
| order_by | Sort a grouped table expression by expr. |
| over | Apply a window over the input expressions. |
| select | Project new columns out of the grouped table. |
aggregate
aggregate(*metrics, **kwds)Compute aggregates over a group by.
count
count()Computing the number of rows per group.
Returns
| Name | Type | Description |
|---|---|---|
| Table | The aggregated table |
having
having(*predicates)Add a post-aggregation result filter expr.
WarningExpressions like
x is None return bool and will not generate a SQL comparison to NULL
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| predicates | ir.BooleanScalar | Expressions that filters based on an aggregate value. | () |
Returns
| Name | Type | Description |
|---|---|---|
| GroupedTable | A grouped table expression |
mutate
mutate(*exprs, **kwexprs)Return a table projection with window functions applied.
Any arguments can be functions.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| exprs | ir.Value | Sequence[ir.Value] | List of expressions | () |
| kwexprs | ir.Value | Expressions | {} |
Examples
>>> (
... t.select("species", "bill_length_mm")
... .group_by("species")
... .mutate(centered_bill_len=ibis._.bill_length_mm - ibis._.bill_length_mm.mean())
... .order_by(s.all())
... )Returns
| Name | Type | Description |
|---|---|---|
| Table | A table expression with window functions applied |
order_by
order_by(*by)Sort a grouped table expression by expr.
Notes
This API call is ignored in aggregations.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| by | ir.Value | Expressions to order the results by | () |
Returns
| Name | Type | Description |
|---|---|---|
| GroupedTable | A sorted grouped GroupedTable |
over
over(window=None, *, rows=None, range=None, group_by=None, order_by=None)Apply a window over the input expressions.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| window | Window to add to the input | None |
|
| rows | Whether to use the ROWS window clause |
None |
|
| range | Whether to use the RANGE window clause |
None |
|
| group_by | Grouping key | None |
|
| order_by | Ordering key | None |
Returns
| Name | Type | Description |
|---|---|---|
| GroupedTable | A new grouped table expression |
select
select(*exprs, **kwexprs)Project new columns out of the grouped table.