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

# unpack_list

> Unpack (extract) items from a column of lists into separate columns. 

The first output column will contain the items in the first position of the input lists, the second column items in the second position etc.

## Usage

The following examples show how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      Extract the first 3 items from a list column into separate columns

      ```stan theme={null}
      unpack_list(ds.coordinates, {"n_items": 3}) => (ds.coord_parts)
      ```
    </Tab>

    <Tab title="Example 2">
      Extract items at positions 1 and 2 with a custom prefix

      ```stan theme={null}
      unpack_list(ds.names, {"start": 1, "n_items": 2, "prefix": "name"}) => (ds.name_parts)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      unpack_list(lists: list, {
          "param": value,
          ...
      }) -> (list_items: dataset)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="lists" type="column[list]" required>
    An input column containing lists to unpack.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="list_items" type="dataset" required>
    The output dataset containing list elements in individual columns.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="start" type="integer" default="0">
    List index of first element to extract.

    Values must be in the following range:

    ```javascript theme={null}
    0 ≤ start < inf
    ```
  </ParamField>

  <ParamField path="n_items" type="integer" default="1">
    Total number of consecutive items to extract from lists.

    Values must be in the following range:

    ```javascript theme={null}
    1 ≤ n_items < inf
    ```
  </ParamField>

  <ParamField path="prefix" type="[string, null]">
    Prefix for names of generated columns.
    By default, will use the output dataset's name concatenated with "\_0", "\_1" etc. for the first
    extracted column, the second column etc. respectively. I.e. you name the output dataset of this step
    `list_items`, then its columns will be named "list\_items\_0", "list\_items\_1" etc. If a prefix is provided,
    this will be used *instead* of the output dataset's name.
  </ParamField>

  <ParamField path="column_names" type="array[string]">
    A list of names for the columns in the output dataset.
    Will be used only if the number of names passed matches the `n_items` parameter.

    <Accordion title="Array items">
      <ParamField path="Item" type="string">
        The name of a single column in the ouput.
      </ParamField>
    </Accordion>
  </ParamField>
</Accordion>
