Skip to content

Convert Series to DataFrame

Source code

Description

Convert Series to DataFrame

Usage

<Series>$to_frame()

Value

DataFrame

Examples

library("polars")

# default will be a DataFrame with empty name
as_polars_series(1:4)$to_frame()
#> shape: (4, 1)
#> ┌─────┐
#> │     │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> └─────┘
as_polars_series(1:4, "bob")$to_frame()
#> shape: (4, 1)
#> ┌─────┐
#> │ bob │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> └─────┘