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
A | B | C | ||
---|---|---|---|---|
int32 | int32 | int32 | ||
0 | NA | NA | 1 | |
1 | 1 | 2 | 2 | |
2 | 2 | 3 | 1 | |
3 | NA | 4 | 1 | |
4 | 2 | 5 | 2 |
Count missing values in all the columns:
DT[:, dt.countna(f[:])]
A | B | C | ||
---|---|---|---|---|
int64 | int64 | int64 | ||
0 | 2 | 1 | 0 |
Count missing values in the column B
only:
DT[:, dt.countna(f.B)]
B | ||
---|---|---|
int64 | ||
0 | 1 |
When no cols
is passed, this function will always return zero:
DT[:, dt.countna()]
C0 | ||
---|---|---|
int64 | ||
0 | 0 |
See Also¶
count()
– function to count the number of non-missing values.
The content on this page is licensed under the Creative Commons Attribution 4.0 License
(CC BY 4.0) ,
and code samples are licensed under the MIT License.