size
Syntax
size(X)
Parameters
X is a scalar/vector/matrix/table.
Details
For a vector/matrix, size returns the number of elements. In
comparison, count returns the number of non-null elements.
For an in-memory table, size returns the number of rows.
Note:
DolphinDB's
size function returns the total
number of the elements in the input object: for a vector or matrix, it returns the
total element count; for an in-memory table, it returns the number of rows. NumPy's
size function returns the number of array elements along a
specified axis. If you do not specify the axis parameter, it returns the
total number of elements across all dimensions; if you do specify axis, it
returns the number of elements along that dimension.Examples
size(3 NULL 5 6);
// output: 4
count(3 NULL 5 6);
// output: 3
m=1 2 3 NULL 4 5$2:3;
m;
| #0 | #1 | #2 |
|---|---|---|
| 1 | 3 | 4 |
| 2 | 5 |
size(m);
// output: 6
count(m);
// output: 5
t = table(1 NULL 3 as id, 3 NULL 9 as qty);
t;
| id | qty |
|---|---|
| 1 | 3 |
| 3 | 9 |
size(t);
// output: 3
count(t);
// output: 3
