Method: Polars::Selectors.decimal

Defined in:
lib/polars/selectors.rb

.decimalSelector

Select all decimal columns.

Examples:

df = Polars::DataFrame.new(
  {
    "foo" => ["x", "y"],
    "bar" => [BigDecimal("123"), BigDecimal("456")],
    "baz" => [BigDecimal("2.0005"), BigDecimal("-50.5555")],
  },
  schema_overrides: {"baz" => Polars::Decimal.new(10, 5)}
)

Select all decimal columns:

df.select(Polars.cs.decimal)
# =>
# shape: (2, 2)
# ┌───────────────┬───────────────┐
# │ bar           ┆ baz           │
# │ ---           ┆ ---           │
# │ decimal[38,0] ┆ decimal[10,5] │
# ╞═══════════════╪═══════════════╡
# │ 123           ┆ 2.00050       │
# │ 456           ┆ -50.55550     │
# └───────────────┴───────────────┘

Select all columns except the decimal ones:


df.select(~Polars.cs.decimal)
# =>
# shape: (2, 1)
# ┌─────┐
# │ foo │
# │ --- │
# │ str │
# ╞═════╡
# │ x   │
# │ y   │
# └─────┘

Returns:



1104
1105
1106
1107
# File 'lib/polars/selectors.rb', line 1104

def self.decimal
  # TODO: allow explicit selection by scale/precision?
  Selector._from_rbselector(RbSelector.decimal)
end