polars is-in
for expression
Creates an is-in expression or checks to see if the elements are contained in the right series
This command requires a plugin
The polars is-in
command resides in the polars
plugin. To use this command, you must install and register nu_plugin_polars
. See the Plugins chapter in the book for more information.
Signature
> polars is-in {flags} (list)
Parameters
list
: List to check if values are in
Input/output types:
input | output |
---|---|
any | any |
Examples
Creates a is-in expression
> 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 │
╰───┴───────┴───┴───────╯
Checks if elements from a series are contained in right series
> let other = ([1 3 6] | polars into-df);
[5 6 6 6 8 8 8] | polars into-df | polars is-in $other
╭───┬───────╮
│ # │ is_in │
├───┼───────┤
│ 0 │ false │
│ 1 │ true │
│ 2 │ true │
│ 3 │ true │
│ 4 │ false │
│ 5 │ false │
│ 6 │ false │
╰───┴───────╯