tabsdata.tableframe.expr.expr.Expr.fill_null#

Expr.fill_null(value: Any | Expr | None = None, strategy: Literal['forward', 'backward', 'min', 'max', 'mean', 'zero', 'one'] | None = None, limit: int | None = None) Expr[source]#

Replace null values with the given value.

Parameters:
  • value – The value to replace null values with.

  • strategy – The strategy to use for filling null values.

  • limit – The maximum number of null values to replace.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("val"), td.col("val")
>>>        .fill_null(5.5).alias("fill_null"))
>>>
┌──────┬───────────┐
│ val  ┆ fill_null │
│ ---  ┆ ---       │
│ f64  ┆ f64       │
╞══════╪═══════════╡
│ -1.0 ┆ -1.0      │
│ 0.0  ┆ 0.0       │
│ 1.1  ┆ 1.1       │
│ 2.0  ┆ 2.0       │
│ inf  ┆ inf       │
│ null ┆ 5.5       │
│ NaN  ┆ NaN       │
└──────┴───────────┘