GroupedTable
**kwargs) GroupedTable(
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
*metrics, **kwds) aggregate(
Compute aggregates over a group by.
count
count()
Computing the number of rows per group.
Returns
Name | Type | Description |
---|---|---|
Table | The aggregated table |
having
*predicates) having(
Add a post-aggregation result filter expr
.
Expressions 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
*exprs, **kwexprs) mutate(
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
>>> import ibis
>>> import ibis.selectors as s
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t
>>> (
"species", "bill_length_mm")
... t.select("species")
... .group_by(=ibis._.bill_length_mm - ibis._.bill_length_mm.mean())
... .mutate(centered_bill_lenall())
... .order_by(s. ... )
Returns
Name | Type | Description |
---|---|---|
Table | A table expression with window functions applied |
order_by
*by) order_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
=None, *, rows=None, range=None, group_by=None, order_by=None) over(window
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
*exprs, **kwexprs) select(
Project new columns out of the grouped table.