> ## 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.

# atoti.MultiColumnArrayConversion

### *final class* atoti.MultiColumnArrayConversion

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

Groups of a least 2 columns named as `"f{prefix}_{index}"` (indices being consecutive and starting with 0 or 1) can be converted into array columns.

### Example

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

`external_table` has 5 QUANTITY\_\{index} columns:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> list(external_table)
['PRODUCT', 'QUANTITY_0', 'QUANTITY_1', 'QUANTITY_2', 'QUANTITY_3', 'QUANTITY_4']
```

and its content is:

| PRODUCT    | QUANTITY\_0 | QUANTITY\_1 | QUANTITY\_2 | QUANTITY\_3 | QUANTITY\_4 |
| ---------- | ----------- | ----------- | ----------- | ----------- | ----------- |
| product\_1 | 10          | 20          | 15          | 25          | 10          |
| product\_2 | 50          | 65          | 55          | 30          | 80          |

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> table = session.add_external_table(
...     external_table,
...     config=TableConfig(
...         array_conversion=tt.MultiColumnArrayConversion(
...             column_prefixes={"QUANTITY"},
...         ),
...         keys={"PRODUCT"},
...     ),
...     table_name="Sales (Multi column 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]
```

<Callout icon="link">
  **See also**:
  [`AutoMultiColumnArrayConversion`](./atoti.directquery.array_conversion.auto_multi_column_array_conversion#atoti.AutoMultiColumnArrayConversion)
</Callout>

#### column\_prefixes *: [Set](https://docs.python.org/3/library/collections.abc.html#collections.abc.Set)\[[str](https://docs.python.org/3/library/stdtypes.html#str)]*

The prefixes of the array element columns in the external table.

One array column per prefix will be created.
