DataFrame.fromNamesAndData constructor

DataFrame.fromNamesAndData(
  1. List<String> columnNames,
  2. DataMatrix data
)

Build a dataframe from specified columnNames and data. The data is expected to be of the shape (rows x columns).

Implementation

factory DataFrame.fromNamesAndData(
    List<String> columnNames, DataMatrix data) {
  if (data.isEmpty) {
    throw ArgumentError(
        'Did not receive any data; Use DataFrame.empty() to create an empty DataFrame');
  }
  if (columnNames.length != data.first.length) {
    throw ArgumentError('Number of column names = ${columnNames.length} does '
        'not match number of data column = ${data.first.length}');
  }
  return DataFrame._default(columnNames, data);
}