duplicate
Repeats rows or whole dataframes: duplicateRows repeats rows inside a DataFrame, duplicate on a DataRow makes a DataFrame out of copies of the row, and duplicate on a DataFrame makes a FrameColumn out of copies of the whole dataframe.
Related operations: Append / duplicate rows
The number of copies n counts the original too, so n = 1 gives one copy. n must be greater than 0. For n = 0 or a negative n, every duplicate and duplicateRows call throws an IllegalArgumentException.
Every example on this page uses the same DataFrame:
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. The examples use the df shown at the top of this page.
With a row condition, only the rows that match it are repeated. The other rows appear once, as before:
Values in column groups and frame columns are repeated together with their rows. The column names and types stay the same.
Don't confuse duplicateRows with distinct, which removes repeated rows.
duplicate on a DataRow
Returns a DataFrame with n rows, each of them a copy of the row. The example uses the df shown at the top of this page.
The result has the same columns as the dataframe the row comes from, column groups and frame columns included. The type of each column follows the value in the row: a nullable column whose value in the row is not null becomes non-nullable in the result. Here name is String? in people, and String in the copies of the first row:
Output:
duplicate on a DataFrame
Returns a FrameColumn with n cells, each holding the whole dataframe. The column has an empty name. The example uses the df shown at the top of this page.
A dataframe gives a column without a name the name untitled, so the table above shows it this way.
To get one DataFrame with all rows of df, followed by all rows of df again, concat the copies: