Skip to content

To polars Series

Source code

Description

as_polars_series() is a generic function that converts an R object to a polars Series.

Usage

as_polars_series(x, name = NULL, ...)

# Default S3 method:
as_polars_series(x, name = NULL, ...)

# S3 method for class 'RPolarsSeries'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'RPolarsExpr'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'RPolarsThen'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'RPolarsChainedThen'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'POSIXlt'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'data.frame'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'vctrs_rcrd'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'Array'
as_polars_series(x, name = NULL, ..., rechunk = TRUE)

# S3 method for class 'ChunkedArray'
as_polars_series(x, name = NULL, ..., rechunk = TRUE)

# S3 method for class 'RecordBatchReader'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'nanoarrow_array'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'nanoarrow_array_stream'
as_polars_series(x, name = NULL, ..., experimental = FALSE)

# S3 method for class 'clock_time_point'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'clock_sys_time'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'clock_zoned_time'
as_polars_series(x, name = NULL, ...)

# S3 method for class 'list'
as_polars_series(x, name = NULL, ...)

Arguments

x Object to convert into a polars Series.
name A character to use as the name of the Series. If NULL (default), the name of x is used or an empty character ““ will be used if x has no name.
Additional arguments passed to methods.
rechunk A logical flag (default TRUE). Make sure that all data is in contiguous memory.
experimental If TRUE, use experimental Arrow C stream interface inside the function. This argument is experimental and may be removed in the future.

Value

a Series

Examples

library("polars")

as_polars_series(1:4)
#> polars Series: shape: (4,)
#> Series: '' [i32]
#> [
#>  1
#>  2
#>  3
#>  4
#> ]
as_polars_series(list(1:4))
#> polars Series: shape: (1,)
#> Series: '' [list[i32]]
#> [
#>  [1, 2, … 4]
#> ]
as_polars_series(data.frame(a = 1:4))
#> polars Series: shape: (4,)
#> Series: '' [struct[1]]
#> [
#>  {1}
#>  {2}
#>  {3}
#>  {4}
#> ]
as_polars_series(as_polars_series(1:4, name = "foo"))
#> polars Series: shape: (4,)
#> Series: 'foo' [i32]
#> [
#>  1
#>  2
#>  3
#>  4
#> ]
as_polars_series(pl$lit(1:4))
#> polars Series: shape: (4,)
#> Series: '' [i32]
#> [
#>  1
#>  2
#>  3
#>  4
#> ]
# Nested type support
as_polars_series(list(data.frame(a = I(list(1:4)))))
#> polars Series: shape: (1,)
#> Series: '' [list[struct[1]]]
#> [
#>  [{[1, 2, … 4]}]
#> ]