DataFrame class

DataFrame for all sorts of data accumulation, analysis & manipulation and collection tasks.

Row access is granted through regular indexing, as DataFrame extends the data matrix of shape (rows x columns). Columns may be accessed via dataframe('columnName').

Inheritance

Constructors

DataFrame.empty()
Returns an empty dataframe.
DataFrame.fromNamesAndData(List<String> columnNames, DataMatrix data)
Build a dataframe from specified columnNames and data. The data is expected to be of the shape (rows x columns).
factory
DataFrame.fromRowMaps(List<RecordRowMap> rowMaps)
Builds a dataframe from a list of rowMaps, e.g. [{'col1': 420, 'col2': 69}, {'col1': 666, 'col2': 1470}].

Properties

columnNames List<String>
no setter
first RecordRow
The first element.
getter/setter pairinherited
hashCode int
Returns hashCode accounting for both the data and _trackedColumnNames
no setteroverride
isEmpty bool
Whether this collection has no elements.
no setterinherited
isNotEmpty bool
Whether this collection has at least one element.
no setterinherited
iterator Iterator<RecordRow>
A new Iterator that allows iterating the elements of this Iterable.
no setterinherited
l List<RecordRow>
finalinherited
last RecordRow
The last element.
getter/setter pairinherited
length int
The number of objects in this list.
getter/setter pairinherited
nColumns int
Returns the number of columns currently held by the instance.
no setter
reversed Iterable<RecordRow>
An Iterable of the objects in this list in reverse order.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shape List<int>
Returns an unmodifiable list of nRows, nColumns.
no setter
single RecordRow
Checks that this iterable has only one element, and returns that element.
no setterinherited

Methods

add(RecordRow element) → void
Adds value to the end of this list, extending the length by one.
inherited
addAll(Iterable<RecordRow> iterable) → void
Appends all objects of iterable to the end of this list.
inherited
addColumn(String name, RecordCol records) → void
Add a new column to the end of the dataframe. The records have to be of the same length as the dataframe.
addRowFromMap(RecordRowMap rowMap) → void
Add a new row represented by rowMap of the structure {columnName: record} to the end of the dataframe.
any(bool test(RecordRow element)) bool
Checks whether any element of this iterable satisfies test.
inherited
asMap() Map<int, RecordRow>
An unmodifiable Map view of this list.
inherited
call<T>(String colName, {int start = 0, int? end}) Column<T>
Enables (typed) column access.
cast<R>() List<R>
Returns a view of this list as a list of R instances.
inherited
clear() → void
Removes all objects from this list; the length of the list becomes zero.
inherited
columnAsIterable<T>(String colName, {int start = 0, int? end}) Iterable<T>
Returns an iterable over the records of a column sliced as per start and end.
columnIndex(String colName) int
Accesses column index in O(1).
columnMap() Map<String, RecordCol>
Returns a {columnName: columnData} representation.
columns() Iterable<Column>
Returns an iterable over all columns.
contains(Object? element) bool
Whether the collection contains an element equal to element.
inherited
copy() DataFrame
Returns a copy of the instance.
elementAt(int index) RecordRow
Returns the indexth element.
inherited
every(bool test(RecordRow element)) bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Iterable<T> f(RecordRow element)) Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
fillRange(int start, int end, [RecordRow? fill]) → void
Overwrites a range of elements with fillValue.
inherited
firstWhere(bool test(RecordRow element), {RecordRow orElse()?}) RecordRow
The first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, T combine(T previousValue, RecordRow element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<RecordRow> other) Iterable<RecordRow>
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(RecordRow element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
getRange(int start, int end) Iterable<RecordRow>
Creates an Iterable that iterates over a range of elements.
inherited
Returns a DataFrame consisting of the first nRows rows or less if the instance holds less.
indexOf(Object? element, [int start = 0]) int
The first index of element in this list.
inherited
indexWhere(bool test(RecordRow element), [int start = 0]) int
The first index in the list that satisfies the provided test.
inherited
insert(int index, RecordRow element) → void
Inserts element at position index in this list.
inherited
insertAll(int index, Iterable<RecordRow> iterable) → void
Inserts all objects of iterable at position index in this list.
inherited
join([String separator = ""]) String
Converts each element to a String and concatenates the strings.
inherited
lastIndexOf(Object? element, [int? start]) int
The last index of element in this list.
inherited
lastIndexWhere(bool test(RecordRow element), [int? start]) int
The last index in the list that satisfies the provided test.
inherited
lastWhere(bool test(RecordRow element), {RecordRow orElse()?}) RecordRow
The last element that satisfies the given predicate test.
inherited
map<T>(T f(RecordRow element)) Iterable<T>
The current elements of this iterable modified by toElement.
inherited
masked(List<bool> mask, {bool asView = true}) DataFrame
Returns a masked DataFrame.
multiIndexed(Iterable<int> indices, {bool asView = true}) DataFrame
Returns a DataFrame composed of the rows specified through indices.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
record<T>(int rowIndex, String colName) → T
Grab a (typed) record sitting at dataframecolName.
reduce(RecordRow combine(RecordRow previousValue, RecordRow element)) RecordRow
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
remove(Object? element) bool
Removes the first occurrence of value from this list.
inherited
removeAt(int index) RecordRow
Removes the object at position index from this list.
inherited
removeColumn(String name) RecordCol
Remove a column from the dataframe and return it.
removeLast() RecordRow
Removes and returns the last object in this list.
inherited
removeRange(int start, int end) → void
Removes a range of elements from the list.
inherited
removeWhere(bool test(RecordRow element)) → void
Removes all objects from this list that satisfy test.
inherited
replaceRange(int start, int end, Iterable<RecordRow> newContents) → void
Replaces a range of elements with the elements of replacements.
inherited
retainWhere(bool test(RecordRow element)) → void
Removes all objects from this list that fail to satisfy test.
inherited
rowMaps() List<RecordRowMap>
Returns a list of {columnName: value} Map-representations for each row.
setAll(int index, Iterable<RecordRow> iterable) → void
Overwrites elements with the objects of iterable.
inherited
setRange(int start, int end, Iterable<RecordRow> iterable, [int skipCount = 0]) → void
Writes some elements of iterable into a range of this list.
inherited
shuffle([Random? random]) → void
Shuffles the elements of this list randomly.
inherited
singleWhere(bool test(RecordRow element), {RecordRow orElse()?}) RecordRow
The single element that satisfies test.
inherited
skip(int count) Iterable<RecordRow>
Creates an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(RecordRow element)) Iterable<RecordRow>
Creates an Iterable that skips leading elements while test is satisfied.
inherited
slice({int start = 0, int? end}) → void
Row-slice instance in-place.
sliced({int start = 0, int? end, bool asView = true}) DataFrame
Returns a DataFrame whose rows have been sliced with respect to start & end.
sort([int compare(RecordRow a, RecordRow b)?]) → void
Sorts this list according to the order specified by the compare function.
inherited
sortBy(String colName, {bool ascending = true, bool nullsFirst = true, Comparator<Record?>? compareRecords}) → void
In-place counterpart to sortedBy.
sortedBy(String colName, {bool ascending = true, bool nullsFirst = true, Comparator<Record?>? compareRecords}) DataFrame
Returns a new dataframe sorted by the column colName.
sublist(int start, [int? end]) List<RecordRow>
Returns a new list containing the elements between start and end.
inherited
take(int count) Iterable<RecordRow>
Creates a lazy iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(RecordRow element)) Iterable<RecordRow>
Creates a lazy iterable of the leading elements satisfying test.
inherited
toCsv(String path, {bool includeHeader = true, String? nullRepresentation = null, String fieldDelimiter = ',', String textDelimiter = '"', String eolToken = '\n', Encoding encoding = utf8}) Future<void>
Save the instance as csv to path.
toList({bool growable = true}) List<RecordRow>
Creates a List containing the elements of this Iterable.
inherited
toSet() Set<RecordRow>
Creates a Set containing the same elements as this iterable.
inherited
toString() String
Returns a readable String representation of the instance including its row indices, column names & data
override
transformColumn(String name, dynamic transformElement(dynamic element)) → void
Transform the values corresponding to name as per transformElement in-place.
where(bool test(RecordRow element)) Iterable<RecordRow>
Creates a new lazy Iterable with all elements that satisfy the predicate test.
inherited
whereType<T>() Iterable<T>
Creates a new lazy Iterable with all elements that have type T.
inherited
withColumns(List<String> columnNames, {bool asView = true}) DataFrame
Returns a DataFrame comprised of a subset of present columns specified by columnNames.

Operators

operator +(List<RecordRow> other) List<RecordRow>
Returns the concatenation of this list and other.
inherited
operator ==(Object other) bool
The equality operator.
override
operator [](int index) RecordRow
The object at the given index in the list.
inherited
operator []=(int index, RecordRow value) → void
Sets the value at the given index in the list to value.
inherited

Static Methods

fromCsv({String? path, Stream<List<int>>? rowStream, Encoding decoding = utf8, String fieldDelimiter = ',', String textDelimiter = '"', String eolToken = '\n', bool containsHeader = true, List<String>? columnNames, List<String>? skipColumns, int? maxRows, Set<Record?> parseAsNull = const {}, bool convertNumeric = true, bool convertDates = true, String? datePattern}) Future<DataFrame>
Build a dataframe from csv data.