databricks.koalas.DataFrame.sum

DataFrame.sum(axis=None, numeric_only=True)

Return the sum of the values.

Parameters
axis{index (0), columns (1)}

Axis for the function to be applied on.

numeric_onlybool, default True

Include only float, int, boolean columns. False is not supported. This parameter is mainly for pandas compatibility.

Returns
sumscalar for a Series, and a Series for a DataFrame.

Examples

>>> df = ks.DataFrame({'a': [1, 2, 3, np.nan], 'b': [0.1, 0.2, 0.3, np.nan]},
...                   columns=['a', 'b'])

On a DataFrame:

>>> df.sum()
a    6.0
b    0.6
Name: 0, dtype: float64
>>> df.sum(axis=1)
0    1.1
1    2.2
2    3.3
3    0.0
Name: 0, dtype: float64

On a Series:

>>> df['a'].sum()
6.0