Skip to content

Commit 8639eaa

Browse files
committed
Fix existing doc examples
1 parent 088482d commit 8639eaa

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

python/datafusion/dataframe.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ def into_view(self, temporary: bool = False) -> Table:
327327
>>> df = ctx.sql("SELECT 1 AS value")
328328
>>> view = df.into_view()
329329
>>> ctx.register_table("values_view", view)
330-
>>> df.collect() # The DataFrame is still usable
331-
>>> ctx.sql("SELECT value FROM values_view").collect()
330+
>>> result = ctx.sql("SELECT value FROM values_view").collect()
331+
>>> result[0].column("value").to_pylist()
332+
[1]
332333
"""
333334
from datafusion.catalog import Table as _Table
334335

@@ -1389,9 +1390,12 @@ def fill_null(self, value: Any, subset: list[str] | None = None) -> DataFrame:
13891390
DataFrame with null values replaced where type casting is possible
13901391
13911392
Examples:
1392-
>>> df = df.fill_null(0) # Fill all nulls with 0 where possible
1393-
>>> # Fill nulls in specific string columns
1394-
>>> df = df.fill_null("missing", subset=["name", "category"])
1393+
>>> from datafusion import SessionContext, col
1394+
>>> ctx = SessionContext()
1395+
>>> df = ctx.from_pydict({"a": [1, None, 3], "b": [None, 5, 6]})
1396+
>>> filled = df.fill_null(0)
1397+
>>> filled.sort(col("a")).collect()[0].column("a").to_pylist()
1398+
[0, 1, 3]
13951399
13961400
Notes:
13971401
- Only fills nulls in columns where the value can be cast to the column type

0 commit comments

Comments
 (0)