Skip to content

Sum

Source code

Description

Aggregate the columns of this DataFrame to their sum values.

Usage

<DataFrame>$sum()

Value

A DataFrame with one row.

Examples

library(polars)

pl$DataFrame(mtcars)$sum()
#> shape: (1, 11)
#> ┌───────┬───────┬────────┬────────┬───┬──────┬──────┬───────┬──────┐
#> │ mpg   ┆ cyl   ┆ disp   ┆ hp     ┆ … ┆ vs   ┆ am   ┆ gear  ┆ carb │
#> │ ---   ┆ ---   ┆ ---    ┆ ---    ┆   ┆ ---  ┆ ---  ┆ ---   ┆ ---  │
#> │ f64   ┆ f64   ┆ f64    ┆ f64    ┆   ┆ f64  ┆ f64  ┆ f64   ┆ f64  │
#> ╞═══════╪═══════╪════════╪════════╪═══╪══════╪══════╪═══════╪══════╡
#> │ 642.9 ┆ 198.0 ┆ 7383.1 ┆ 4694.0 ┆ … ┆ 14.0 ┆ 13.0 ┆ 118.0 ┆ 90.0 │
#> └───────┴───────┴────────┴────────┴───┴──────┴──────┴───────┴──────┘