Datacat class

A versatile data structure resembling a DataFrame. It holds column names and rows of data and can optionally enforce a schema. It also provides static methods to create nested Datacats from JSON.

Constructors

Datacat({required List<String> columns, required List<List> rows})
Datacat.fromJsonString(String jsonString)
Creates a Datacat from a JSON string representing a list of objects.
factory
Datacat.withSchema({required DatacatSchema schema, required List<List> rows})
Creates a Datacat that enforces the provided schema. The columns are set to the keys from schema.requiredColumns. Throws an error if the provided rows do not conform.

Properties

columns List<String>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
rows List<List>
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addRow(List row) → void
Adds a new row. Throws if the row length doesn't match columns.
describe() Map<String, Map<String, num>>
Computes summary statistics for numeric columns. Returns a map mapping each numeric column to a map of count, sum, mean, min, and max.
dropColumns(List<String> dropColumns) Datacat
Returns a new Datacat with the specified columns dropped.
fillNA(String columnName, dynamic fillValue) Datacat
Fills missing (null) values in the specified column with fillValue.
groupBy(String columnName) Map<dynamic, Datacat>
Groups rows by the given column and returns a Map from the group key to a Datacat.
Returns a new Datacat containing the first n rows.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
selectColumns(List<String> selectedColumns) Datacat
Returns a new Datacat with only the selected columns.
sortBy(String columnName, {bool ascending = true}) Datacat
Returns a new Datacat sorted by the given column.
tail([int n = 5]) Datacat
Returns a new Datacat containing the last n rows.
toString() String
A string representation of this object.
override
updateCell(int rowIndex, String columnName, dynamic newValue) → void
Updates a cell at rowIndex in column columnName with newValue.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromJsonMapString(String jsonString) Map<String, Datacat>
Creates nested Datacats from a JSON string representing a map, where each key maps to a list of objects. Returns a Map<String, Datacat>.