From 09cfd8568c001335acc542bd42848b37c1796533 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:41:52 -0700 Subject: [PATCH] docs(arbitrary): add example for `arbitrary` method docstring (#9596) --- ibis/expr/types/generic.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py index 9c7fb9e6fe99..fbbbbe9af507 100644 --- a/ibis/expr/types/generic.py +++ b/ibis/expr/types/generic.py @@ -1996,6 +1996,31 @@ def arbitrary( ------- Scalar An expression + + Examples + -------- + >>> import ibis + >>> ibis.options.interactive = True + >>> t = ibis.memtable({"a": [1, 2, 2], "b": list("aaa"), "c": [4.0, 4.1, 4.2]}) + >>> t + ┏━━━━━━━┳━━━━━━━━┳━━━━━━━━━┓ + ┃ a ┃ b ┃ c ┃ + ┡━━━━━━━╇━━━━━━━━╇━━━━━━━━━┩ + │ int64 │ string │ float64 │ + ├───────┼────────┼─────────┤ + │ 1 │ a │ 4.0 │ + │ 2 │ a │ 4.1 │ + │ 2 │ a │ 4.2 │ + └───────┴────────┴─────────┘ + >>> t.group_by("a").agg(arb=t.b.arbitrary(), c=t.c.sum()) + ┏━━━━━━━┳━━━━━━━━┳━━━━━━━━━┓ + ┃ a ┃ arb ┃ c ┃ + ┡━━━━━━━╇━━━━━━━━╇━━━━━━━━━┩ + │ int64 │ string │ float64 │ + ├───────┼────────┼─────────┤ + │ 2 │ a │ 8.3 │ + │ 1 │ a │ 4.0 │ + └───────┴────────┴─────────┘ """ if how is not None: warn_deprecated(