Skip to content

Commit

Permalink
docs(name): improve docstring of ibis.param API
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 17, 2023
1 parent dd66af2 commit 2f9ec90
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,22 @@ def param(type: dt.DataType) -> ir.Scalar:
Examples
--------
>>> from datetime import date
>>> import ibis
>>> start = ibis.param("date")
>>> end = ibis.param("date")
>>> schema = dict(timestamp_col="timestamp", value="double")
>>> t = ibis.table(schema, name="t")
>>> predicates = [t.timestamp_col >= start, t.timestamp_col <= end]
>>> t.filter(predicates).value.sum()
r0 := UnboundTable: t
timestamp_col timestamp
value float64
r1 := Selection[r0]
predicates:
r0.timestamp_col >= $(date)
r0.timestamp_col <= $(date)
Sum(value): Sum(r1.value)
>>> t = ibis.memtable(
... {
... "date_col": [date(2013, 1, 1), date(2013, 1, 2), date(2013, 1, 3)],
... "value": [1.0, 2.0, 3.0],
... },
... )
>>> expr = t.filter(t.date_col >= start).value.sum()
>>> expr.execute(params={start: date(2013, 1, 1)})
6.0
>>> expr.execute(params={start: date(2013, 1, 2)})
5.0
>>> expr.execute(params={start: date(2013, 1, 3)})
3.0
"""
return ops.ScalarParameter(type).to_expr()

Expand Down

0 comments on commit 2f9ec90

Please sign in to comment.