polars is-in
For expression.
Creates an is-in expression or checks to see if the elements are contained in the right series
warning This command requires a plugin The
polars is-incommand 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 is-in {flags} (list)
Flags
--maintain-order, -o: Maintains the order of the original values in the list
Parameters
list: List to check if values are in.
Input/output types:
| input | output |
|---|---|
| polars_expression | polars_expression |
| polars_selector | polars_expression |
Examples
Creates a is-in expression using a list
> let df = ([[a b]; [one 1] [two 2] [three 3]] | polars into-df);
$df | polars with-column (polars col a | polars is-in [one two] | polars as a_in)
╭───┬───────┬───┬───────╮
│ # │ a │ b │ a_in │
├───┼───────┼───┼───────┤
│ 0 │ one │ 1 │ true │
│ 1 │ two │ 2 │ true │
│ 2 │ three │ 3 │ false │
╰───┴───────┴───┴───────╯
Creates a is-in expression using a polars series
> let df = ([[a b]; [one 1] [two 2] [three 3]] | polars into-df);
$df | polars with-column (polars col a | polars is-in ([one two] | polars into-df) | polars as a_in)
╭───┬───────┬───┬───────╮
│ # │ a │ b │ a_in │
├───┼───────┼───┼───────┤
│ 0 │ one │ 1 │ true │
│ 1 │ two │ 2 │ true │
│ 2 │ three │ 3 │ false │
╰───┴───────┴───┴───────╯
Creates a is-in expression using a polars expr
> let df = ([[a b]; [one 1] [two 2] [three 3]] | polars into-df);
$df | polars with-column (polars col a | polars is-in (polars lit [one two] | polars implode) | polars as a_in)
╭───┬───────┬───┬───────╮
│ # │ a │ b │ a_in │
├───┼───────┼───┼───────┤
│ 0 │ one │ 1 │ true │
│ 1 │ two │ 2 │ true │
│ 2 │ three │ 3 │ false │
╰───┴───────┴───┴───────╯
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.