polars fill-null
For lazyframe.
Replaces NULL values with the given expression.
warning This command requires a plugin The
polars fill-nullcommand resides in thepolarsplugin. To use this command, you must install and registernu_plugin_polars. See the Plugins chapter in the book for more information.
Command Type
plugin
Signature
> polars fill-null {flags} (fill)
Parameters
fill: Expression to use to fill the null values.
Input/output types:
| input | output |
|---|---|
| polars_dataframe | polars_dataframe |
| polars_lazyframe | polars_lazyframe |
| polars_expression | polars_expression |
| polars_selector | polars_expression |
Examples
Fills the null values by 0
> [1 2 2 3 3] | polars into-df | polars shift 2 | polars fill-null 0
╭───┬───╮
│ # │ 0 │
├───┼───┤
│ 0 │ 0 │
│ 1 │ 0 │
│ 2 │ 1 │
│ 3 │ 2 │
│ 4 │ 2 │
╰───┴───╯
Fills the null values in expression
> [[a]; [1] [2] [2] [3] [3]]
| polars into-df
| polars select (polars col a | polars shift 2 | polars fill-null 0)
| polars collect
╭───┬───╮
│ # │ a │
├───┼───┤
│ 0 │ 0 │
│ 1 │ 0 │
│ 2 │ 1 │
│ 3 │ 2 │
│ 4 │ 2 │
╰───┴───╯
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.