Convert a DataFrame to a Series of type Struct
Description
Convert a DataFrame to a Series of type Struct
Usage
<DataFrame>$to_struct(name = "")
Arguments
name
|
A character. Name for the struct Series. |
Value
A Series of the struct type
See Also
-
as_polars_series()
Examples
library("polars")
df <- pl$DataFrame(
a = 1:5,
b = c("one", "two", "three", "four", "five"),
)
df$to_struct("nums")
#> shape: (5,)
#> Series: 'nums' [struct[2]]
#> [
#> {1,"one"}
#> {2,"two"}
#> {3,"three"}
#> {4,"four"}
#> {5,"five"}
#> ]