withTail method
A new data frame with only the last n
rows.
Example:
print(petals.withTail(3));
.---.------------.-----------.-----------.
|id |petal_length|petal_width|species |
:---+------------+-----------+-----------:
|102|5.1 |1.9 |virginica |
|103|5.9 |2.1 |virginica |
|104|5.6 |1.8 |virginica |
'---'------------'-----------'-----------'
Implementation
DataFrame withTail([int n = 10]) {
final numberOfRows = this.rowNumber;
return withRowsAtIndices(
[for (var i = math.max(0, numberOfRows - n); i < numberOfRows; i++) i]);
}