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”
withcs$contains(“oo”) & cs$ends_with(“t”)
; -
|
to combine conditions with OR, e.g. select columns that contain“oo”
or end with“t”
withcs$contains(“oo”) | cs$ends_with(“t”)
; -
-
to substract conditions, e.g. select all columns that have alphanumeric names except those that contain“a”
withcs$alphanumeric() - cs$contains(“a”)
; -
!
to invert the selection, e.g. select all columns that are not of data typeString
with!cs$string()
.
Note that Python Polars uses ~
instead of !
to
invert selectors.
Examples
#> <polars_object>
#> [1] 29