Skip to content

Polars column selector function namespace

Description

cs is an environment class object that stores all selector functions of the R Polars API which mimics the Python Polars API. It is intended to work the same way in Python as if you had imported Python Polars Selectors with import polars.selectors as cs.

Usage

cs

Format

An object of class polars_object of length 29.

Supported operators

There are 4 supported operators for selectors:

  • & to combine conditions with AND, e.g. select columns that contain “oo” and end with “t” with cs$contains(“oo”) & cs$ends_with(“t”);
  • | to combine conditions with OR, e.g. select columns that contain “oo” or end with “t” with cs$contains(“oo”) | cs$ends_with(“t”);
  • - to substract conditions, e.g. select all columns that have alphanumeric names except those that contain “a” with cs$alphanumeric() - cs$contains(“a”);
  • ! to invert the selection, e.g. select all columns that are not of data type String with !cs$string().

Note that Python Polars uses ~ instead of ! to invert selectors.

Examples

library("polars")

cs
#> <polars_object>
# How many members are in the `cs` environment?
length(cs)
#> [1] 29