withRowsAtIndices method

DataFrame withRowsAtIndices(
  1. Iterable<int> indices
)

A new data frame comprising the rows at indices.

Example:

final d = DataFrame.fromCsv("""
 a,b,c
 1,5.1,"red"
 3,2.7,"green"
 5,-0.9,"red"
""");

print(d.withRowsAtIndices([2, 1, 0, 1, 2]));

.-.----.-------.
|a|b   |c      |
:-+----+-------:
|5|-0.9|red    |
|3|2.7 |green  |
|1|5.1 |red    |
|3|2.7 |green  |
|5|-0.9|red    |
'-'----'-------'

Implementation

DataFrame withRowsAtIndices(Iterable<int> indices) =>
    DataFrame(numericColumns: {
      for (final MapEntry(:key, :value) in numericColumns.entries)
        key: NumericColumn(value.valuesAtIndices(indices))
    }, categoricColumns: {
      for (final MapEntry(:key, :value) in categoricColumns.entries)
        key: CategoricColumn(value.valuesAtIndices(indices))
    });