counts property
The number of times each value occurs in this column.
Example:
final petalWidth = iris.numericColumns["petal_length"]!,
counts = petalWidth.counts,
orderedKeys = [...counts.keys]..sort();
for (final key in orderedKeys) {
print("$key " + "|" * counts[key]!);
}
1.0 |
1.1 |
1.2 ||
1.3 |||||||
1.4 |||||||||||||
1.5 |||||||||||||
1.6 |||||||
1.7 ||||
1.9 ||
3.0 |
3.3 ||
3.5 ||
3.6 |
3.7 |
3.8 |
3.9 |||
4.0 |||||
4.1 |||
4.2 ||||
4.3 ||
4.4 ||||
4.5 ||||||||
4.6 |||
4.7 |||||
4.8 ||||
4.9 |||||
5.0 ||||
5.1 ||||||||
5.2 ||
5.3 ||
5.4 ||
5.5 |||
5.6 ||||||
5.7 |||
5.8 |||
5.9 ||
6.0 ||
6.1 |||
6.3 |
6.4 |
6.6 |
6.7 ||
6.9 |
Implementation
Map<External, int> get counts {
final values = this.values;
return {
for (final v in {...values}) v: values.where((x) => x == v).length
};
}