duplicateRows
Returns a DataFrame where every row is repeated n times.
The copies of a row come right after it, so the order of the rows stays the same: with n = 2, rows A, B become A, A, B, B. Values in column groups and frame columns are repeated together with their rows. The column names and types stay the same.
Don't confuse this with distinct, which removes repeated rows.
For more information: See duplicateRows on the documentation website.
See also:
duplicateRows(n) { filter: RowFilter<T> }— repeats only the rows that match a condition.duplicate— puts copies of the wholeDataFrameinto aFrameColumn.duplicate— makes aDataFrameout of copies of a singleDataRow.
Example
In the example, df has the columns name and age and three rows: Alice, 15, Bob, 20 and Charlie, 30.
// Alice, Alice, Alice, Bob, Bob, Bob, Charlie, Charlie, Charlie
df.duplicateRows(3)Return
Parameters
The number of copies in the result, the original included. Must be greater than 0.
Throws
if n is 0 or negative.
Returns a DataFrame where each row that matches the filter is repeated n times.
Rows that do not match the filter appear once, as before. The copies of a row come right after it, so the order of the rows stays the same. Values in column groups and frame columns are repeated together with their rows. The column names and types stay the same.
The filter is a RowFilter — a lambda that receives each DataRow as both this and it and returns true for the rows to repeat.
It allows you to define conditions using the row's values directly, including through extension properties for convenient and type-safe access.
For more information: See duplicateRows on the documentation website. See RowFilter on the documentation website.
See also:
duplicateRows(n: Int)— repeats every row.filter— keeps only the rows that match a condition.
Example
In the example, df has the columns name and age and three rows: Alice, 15, Bob, 20 and Charlie, 30.
// Alice, Bob, Bob, Bob, Charlie, Charlie, Charlie
df.duplicateRows(3) { age > 18 }Return
A DataFrame where the rows that match the filter are repeated n times and the other rows appear once.
Parameters
The condition that selects the rows to repeat.
The number of copies in the result, the original included. Must be greater than 0.
Throws
if n is 0 or negative.