Skip to content

Polars Series class (polars_series)

Source code

Description

Series are a 1-dimensional data structure, which are similar to R vectors. Within a series all elements have the same Data Type.

Usage

pl$Series(name = NULL, values = NULL)

Arguments

name A single string or NULL. Name of the Series. Will be used as a column name when used in a polars DataFrame. When not specified, name is set to an empty string.
values An R object. Passed as the x param of as_polars_series().

Details

The pl$Series() function mimics the constructor of the Series class of Python Polars. This function calls as_polars_series() internally to convert the input object to a Polars Series.

Active bindings

  • dtype: $dtype returns the data type of the Series.
  • name: $name returns the name of the Series.
  • shape: $shape returns a integer vector of length two with the number of length of the Series and width of the Series (always 1).

See Also

  • as_polars_series()

Examples

library("polars")

# Constructing a Series by specifying name and values positionally:
s <- pl$Series("a", 1:3)
s
#> shape: (3, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> └─────┘
# Active bindings:
s$dtype
#> Int32
s$name
#> [1] "a"
s$shape
#> [1] 3 1