parseAsMapOfLists method

DataFrame parseAsMapOfLists({
  1. Map<String, ColumnType>? types,
})

Creates a data frame from a json string representing a map of lists.

Example:

final d = """
  {
    "a": [1, 2, 3],
    "b": [3.2, -5.6, 0.0],
    "c": ["apple", "ball", "cat"]
  }
""".parseAsMapOfLists();
print(d);

.-.----.-------.
|a|b   |c      |
:-+----+-------:
|1|3.2 |apple  |
|2|-5.6|ball   |
|3|0.0 |cat    |
'-'----'-------'

Implementation

DataFrame parseAsMapOfLists({Map<String, ColumnType>? types}) {
  final data = <String, List<Object>>{};
  // Hack: convert json.decode value...
  for (final MapEntry(:key, :value) in json.decode(this).entries) {
    data[key] = [...value];
  }
  return DataFrame.fromMapOfLists(
    data,
    types: types,
  );
}