Skip to main content

Table.expand_to_rows

expand_to_rowscolumnat_least_one_row

Group: Calculations

Documentation

Expand aggregate values in a column to separate rows. For each value in the specified column, if it is an aggregate (Vector, Range, etc.), expand it to multiple rows, duplicating the values in the other columns.

The following values are considered sequence-like: - Array - Vector - List - Range - Date_Range - Pair - Table (interpreted as a sequence of Rows) - Column Some aggregates, like dictionaries will expand into two columns - one for key and one for the value. If a value is not an aggregate, or has no defined way of being expanded, it is left as a single row containing that value unchanged. In in-memory tables, it is permitted to mix values of different types.

Arguments

  • column: The column to expand.
  • at_least_one_row: for an empty aggregate value, if at_least_one_row is true, a single row is output with Nothing for the aggregates column; if false, no row is output at all.

Examples

Expand a column of integer Vectors to a column of Integer

table = Table.new [["aaa", [1, 2]], ["bbb", [[30, 31], [40, 41]]]]

=> Table.new [["aaa", [1, 1, 2, 2]], ["bbb", [30, 31, 40, 41]]]