Skip to main content

Table.add_row_number

add_row_numbernamefromstepgroup_byorder_byon_problems

Group: Values
Aliases: add index column, rank, record id

Documentation

Adds a new column to the table enumerating the rows.

Arguments

  • name: The name of the new column. Defaults to "Row".
  • from: The starting value for the enumeration. Defaults to 1.
  • step: The amount to increment the enumeration by. Defaults to 1.
  • group_by: Specifies the columns to group by. The row numbers are counted separately for each group. By default, all rows are treated as a single group.
  • order_by: Specifies the columns to order by. Defaults to the order of the rows in the table. The row numbers are assigned according to the specified ordering.

Errors

  • If the columns specified in group_by or order_by are not present in the table, a Missing_Input_Columns error is raised.
  • If the column with the same name as provided name already exists, a Duplicate_Output_Column_Names problem is reported and the existing column is renamed to avoid the clash.
  • If grouping on floating point numbers, a Floating_Point_Equality problem is reported.

Remarks

Ordering of rows

Note that the ordering of rows from the original table is preserved in all cases. The grouping and ordering settings affect how the row numbers are assigned to each row, but the order of the rows itself is not changed by this operation.