polars.Series.sum#

Series.sum() int | float[source]#

Reduce this Series to the sum value.

Notes

  • Dtypes in {Int8, UInt8, Int16, UInt16} are cast to Int64 before summing to prevent overflow issues.

  • If there are no non-null values, then the output is 0. If you would prefer empty sums to return None, you can use s.sum() if s.count() else None instead of s.sum().

Examples

>>> s = pl.Series("a", [1, 2, 3])
>>> s.sum()
6