> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MultiRowArrayConversion

> atoti.MultiRowArrayConversion(\
>
>     \*,\
>
>     *index\_column*: [str](https://docs.python.org/3/builtins/stdtypes.html#str),\
>
>     *array\_columns*: [Set](https://docs.python.org/3/library/collections.abc.html#collections.abc.Set)\[[str](https://docs.python.org/3/builtins/stdtypes.html#str)],\
>
> )

Convert an external table where array values are stored with one value per row to a table with array columns.

The external table must have an [`index_column`](#atoti.MultiRowArrayConversion.index_column) and at least one “value” column representing the array elements.

All the table columns except from [`index_column`](#atoti.MultiRowArrayConversion.index_column) and the [`array_columns`](#atoti.MultiRowArrayConversion.array_columns) will become key columns.

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> external_database = session.connect_to_external_database(connection_config)
>>> external_table = external_database.tables["TUTORIAL", "MULTI_ROW_QUANTITY"]
```

`external_table` has an **INDEX** column:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> list(external_table)
['PRODUCT', 'INDEX', 'QUANTITY']
```

and its content is:

| PRODUCT | INDEX | QUANTITY |
| - | - | - |
| product\_1 | 0 | 10 |
| product\_1 | 1 | 20 |
| product\_1 | 2 | 15 |
| product\_1 | 3 | 25 |
| product\_1 | 4 | 10 |
| product\_2 | 0 | 50 |
| product\_2 | 1 | 65 |
| product\_2 | 2 | 55 |
| product\_2 | 3 | 30 |
| product\_2 | 4 | 80 |

It can be converted into a table with an array column:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> table = session.add_external_table(
...     external_table,
...     config=TableConfig(
...         array_conversion=tt.MultiRowArrayConversion(
...             array_columns={"QUANTITY"},
...             index_column="INDEX",
...         ),
...     ),
...     table_name="Sales (Multi row array)",
... )
>>> table.head().sort_index()
                                 QUANTITY
PRODUCT
product_1  [10.0, 20.0, 15.0, 25.0, 10.0]
product_2  [50.0, 65.0, 55.0, 30.0, 80.0]
```

### Attributes

#### *index\_column*

Name of the column used as an index for the arrays.

#### *array\_columns*

Names of the columns that contain array values.
