Skip to content

Shrink numeric values to the minimal required datatype

Source code

Description

Shrink numeric values to the minimal required datatype

Usage

<series>$_shrink_dtype()

Value

A polars Series

Examples

library("polars")

s <- as_polars_series(1:6)
s
#> shape: (6, 1)
#> ┌─────┐
#> │     │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> │ 5   │
#> │ 6   │
#> └─────┘
s$shrink_dtype()
#> shape: (6, 1)
#> ┌─────┐
#> │     │
#> │ --- │
#> │ i8  │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> │ 5   │
#> │ 6   │
#> └─────┘