Skip to content

Commit fe4e2f7

Browse files
timsaucerclaude
andcommitted
Add docstring examples for optional params in string_to_array and gen_series
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7ff0551 commit fe4e2f7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/datafusion/functions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3702,6 +3702,15 @@ def string_to_array(
37023702
... ).alias("result"))
37033703
>>> result.collect_column("result")[0].as_py()
37043704
['hello', 'world']
3705+
3706+
Replace parts matching a ``null_string`` with ``NULL``:
3707+
3708+
>>> result = df.select(
3709+
... dfn.functions.string_to_array(
3710+
... dfn.col("a"), dfn.lit(","), null_string=dfn.lit("world"),
3711+
... ).alias("result"))
3712+
>>> result.collect_column("result")[0].as_py()
3713+
['hello', None]
37053714
"""
37063715
null_expr = null_string.expr if null_string is not None else None
37073716
return Expr(f.string_to_array(string.expr, delimiter.expr, null_expr))
@@ -3732,6 +3741,15 @@ def gen_series(start: Expr, stop: Expr, step: Expr | None = None) -> Expr:
37323741
... ).alias("result"))
37333742
>>> result.collect_column("result")[0].as_py()
37343743
[1, 2, 3, 4, 5]
3744+
3745+
Specify a custom ``step``:
3746+
3747+
>>> result = df.select(
3748+
... dfn.functions.gen_series(
3749+
... dfn.lit(1), dfn.lit(10), step=dfn.lit(3),
3750+
... ).alias("result"))
3751+
>>> result.collect_column("result")[0].as_py()
3752+
[1, 4, 7, 10]
37353753
"""
37363754
step_expr = step.expr if step is not None else None
37373755
return Expr(f.gen_series(start.expr, stop.expr, step_expr))

0 commit comments

Comments
 (0)