Method: Polars::Selectors.binary

Defined in:
lib/polars/selectors.rb

.binarySelector

Select all binary columns.

Examples:

df = Polars::DataFrame.new({"a" => ["hello".b], "b" => ["world"], "c" => ["!".b], "d" => [":)"]})
# =>
# shape: (1, 4)
# ┌──────────┬───────┬────────┬─────┐
# │ a        ┆ b     ┆ c      ┆ d   │
# │ ---      ┆ ---   ┆ ---    ┆ --- │
# │ binary   ┆ str   ┆ binary ┆ str │
# ╞══════════╪═══════╪════════╪═════╡
# │ b"hello" ┆ world ┆ b"!"   ┆ :)  │
# └──────────┴───────┴────────┴─────┘

Select binary columns and export as a hash:

df.select(Polars.cs.binary).to_h(as_series: false)
# => {"a"=>["hello"], "c"=>["!"]}

Select all columns except for those that are binary:

df.select(~Polars.cs.binary).to_h(as_series: false)
# => {"b"=>["world"], "d"=>[":)"]}

Returns:



295
296
297
# File 'lib/polars/selectors.rb', line 295

def self.binary
  by_dtype([Binary])
end