Points.count¶
- Points.count(condition, features=None)¶
The number of points which satisfy the condition.
- Parameters:
condition (function, query) –
function - accepts a point as its only argument and returns a boolean value to indicate if the point should be counted
query - string in the format ‘FEATURENAME OPERATOR VALUE’ (i.e “ft1 < 10”, “id4 == yes”, or “col4 is nonZero”) where OPERATOR is separated from the FEATURENAME and VALUE by whitespace characters. See
nimble.match.QueryString
for string requirements.
features (None, identifier, list of identifiers) – Only apply the condition function to a selection of features in each point. May be a single feature name or index, an iterable, container of feature names and/or indices. None indicates application to all features.
- Returns:
int
Examples
Count using a python function.
>>> def sumIsOne(pt): ... return sum(pt) == 1 >>> X = nimble.identity(3) >>> X.points.count(sumIsOne) 3
Count when the query string returns True.
>>> X = nimble.identity(3, featureNames=['ft1', 'ft2', 'ft3']) >>> X.points.count("ft1 == 0") 2
Keywords: number, counts, tally