datatable.rowmean()

For each row, find the mean values among the columns from cols skipping missing values. If a row contains only the missing values, this function will produce a missing value too.

Parameters

cols
FExpr

Input columns.

return
FExpr

f-expression consisting of one column that has the same number of rows as in cols. The column stype is float32 when all the cols are float32, and float64 in all the other cases.

except
TypeError

The exception is raised when cols has non-numeric columns.

Examples

from datatable import dt, f, rowmean DT = dt.Frame({'a': [None, True, True, True], 'b': [2, 2, 1, 0], 'c': [3, 3, 1, 0], 'd': [0, 4, 6, 0], 'q': [5, 5, 1, 0]}
DT
abcdq
bool8int32int32int32int32
0NA2305
112345
211161
310000

Get the row mean of all columns:

DT[:, rowmean(f[:])]
C0
float64
02.5
13
22
30.2

Get the row mean of specific columns:

DT[:, rowmean(f['a', 'b', 'd'])]
C0
float64
01
12.33333
22.66667
30.333333

See Also

  • rowsd() – calculate the standard deviation row-wise.