groupBy method
Groups rows by the given column and returns a Map from the group key to a Datacat.
Implementation
Map<dynamic, Datacat> groupBy(String columnName) {
int index = columns.indexOf(columnName);
if (index == -1) throw ArgumentError('Column "$columnName" not found.');
Map<dynamic, List<List<dynamic>>> groups = {};
for (var row in rows) {
var key = row[index];
groups.putIfAbsent(key, () => []).add(row);
}
return groups.map((key, value) =>
MapEntry(key, Datacat(columns: List.from(columns), rows: value)));
}