datatable.count()¶
Calculate the number of non-missing values for each column from cols
.
Parameters¶
cols
Expr
Input columns.
return
Expr
f-expression having one row, and the same names and number of columns
as in cols
. All the returned column stypes are int64
.
except
TypeError
The exception is raised when one of the columns from cols
has a non-numeric and non-string type.
Examples¶
from datatable import dt, f
df = dt.Frame({'A': [1, 1, 2, 1, 2],
'B': [None, 2, 3,4, 5],
'C': [1, 2, 1, 1, 2]})
df
A | B | C | ||
---|---|---|---|---|
int32 | int32 | int32 | ||
0 | 1 | NA | 1 | |
1 | 1 | 2 | 2 | |
2 | 2 | 3 | 1 | |
3 | 1 | 4 | 1 | |
4 | 2 | 5 | 2 |
Get the count of all rows:
df[:, dt.count()]
count | ||
---|---|---|
int32 | ||
0 | 5 |
Get the count of column B
(note how the null row is excluded from the
count result):
df[:, dt.count(f.B)]
B | ||
---|---|---|
int64 | ||
0 | 4 |
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.