datatable.countna()

Added in version 1.1.0

Count missing values for each column from cols. This function is group-aware.

Parameters

cols
FExpr

Input columns.

return
FExpr

f-expression that counts the number of missing values for each column from cols. If cols is not provided, it will return 0 for each of the frame’s group. 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 missing values in all the columns:

DT[:, dt.countna(f[:])]
ABC
int64int64int64
0210

Count missing values in the column B only:

DT[:, dt.countna(f.B)]
B
int64
01

When no cols is passed, this function will always return zero:

DT[:, dt.countna()]
C0
int64
00

See Also

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