Skip to content

Commit 2f9ec90

Browse files
committed
docs(name): improve docstring of ibis.param API
1 parent dd66af2 commit 2f9ec90

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

ibis/expr/api.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,21 +244,22 @@ def param(type: dt.DataType) -> ir.Scalar:
244244
245245
Examples
246246
--------
247+
>>> from datetime import date
247248
>>> import ibis
248249
>>> start = ibis.param("date")
249-
>>> end = ibis.param("date")
250-
>>> schema = dict(timestamp_col="timestamp", value="double")
251-
>>> t = ibis.table(schema, name="t")
252-
>>> predicates = [t.timestamp_col >= start, t.timestamp_col <= end]
253-
>>> t.filter(predicates).value.sum()
254-
r0 := UnboundTable: t
255-
timestamp_col timestamp
256-
value float64
257-
r1 := Selection[r0]
258-
predicates:
259-
r0.timestamp_col >= $(date)
260-
r0.timestamp_col <= $(date)
261-
Sum(value): Sum(r1.value)
250+
>>> t = ibis.memtable(
251+
... {
252+
... "date_col": [date(2013, 1, 1), date(2013, 1, 2), date(2013, 1, 3)],
253+
... "value": [1.0, 2.0, 3.0],
254+
... },
255+
... )
256+
>>> expr = t.filter(t.date_col >= start).value.sum()
257+
>>> expr.execute(params={start: date(2013, 1, 1)})
258+
6.0
259+
>>> expr.execute(params={start: date(2013, 1, 2)})
260+
5.0
261+
>>> expr.execute(params={start: date(2013, 1, 3)})
262+
3.0
262263
"""
263264
return ops.ScalarParameter(type).to_expr()
264265

0 commit comments

Comments
 (0)