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 returnNone, you can uses.sum() if s.count() else Noneinstead ofs.sum().
Examples
>>> s = pl.Series("a", [1, 2, 3]) >>> s.sum() 6