datatable.rowsum()

For each row, calculate the sum of all values in cols. Missing values are treated as if they are zeros and skipped during the calcultion.

Parameters

cols
FExpr

Input columns.

return
FExpr

f-expression consisting of one column and the same number of rows as in cols. The stype of the resulting column will be the smallest common stype calculated for cols, but not less than int32.

except
TypeError

The exception is raised when one of the columns from cols has a non-numeric type.

Examples

from datatable import dt, f, rowsum DT = dt.Frame({'a': [1,2,3], 'b': [2,3,4], 'c':['dd','ee','ff'], 'd':[5,9,1]}) DT
abcd
int32int32str32int32
012dd5
123ee9
234ff1
DT[:, rowsum(f[int])]
C0
int32
08
114
28
DT[:, rowsum(f.a, f.b)]
C0
int32
03
15
27

The above code could also be written as

DT[:, f.a + f.b]
C0
int32
03
15
27

See Also

  • rowcount() – count non-missing values row-wise.