datatable.count()

Count non-missing values for each column from cols. When called with no arguments, simply count the number of rows. This function is group-aware.

Parameters

cols
FExpr

Input columns if any.

return
FExpr

f-expression that counts the number of non-missing values for each column from cols. If cols is not provided, it calculates the number of rows. The returned f-expression has as many rows as there are groups, it also has the same names and number of columns as in cols. All the resulting column’s stypes are int64.

except
TypeError

The exception is raised when one of the input columns has an obj64 type.

Examples

from datatable import dt, f DT = dt.Frame({'A': [None, 1, 2, None, 2], 'B': [None, 2, 3, 4, 5], 'C': [1, 2, 1, 1, 2]}) DT
ABC
int32int32int32
0NANA1
1122
2231
3NA41
4252

Count non-missing values in all the columns:

DT[:, dt.count(f[:])]
ABC
int64int64int64
0345

Count non-missing values in the column B only:

DT[:, dt.count(f.B)]
B
int64
04

Get the number of rows in a frame:

DT[:, dt.count()]
count
int64
05

See Also

  • countna() – function to count the number of missing values.