> For the complete documentation index, see [llms.txt](https://cgps.gitbook.io/data-flo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cgps.gitbook.io/data-flo/reference-guide/reshape-long-to-wide.md).

# reshape-long-to-wide

## Description

<mark style="color:purple;">`reshape-long-to-wide`</mark> *adaptor expands a key column and a value column from a datatable into a column for each key and filled in with previously paired values.*

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable in long format.

**`key column name`**\
Type: `text`\
Required: No\
The name of the column to which keys are added. If unspecified, defaults to `key`.

**`value column name`**\
Type: `text`\
Required: No\
The name of the column to which values are added. If unspecified, defaults to `value`.

## Outputs

**`data`**\
Type: `datatable`\
A datatable in wide format.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | code | country        |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |

`key column name:` code

`value column name:` country

#### Outputs:

`data`:

| id | United Kingdom | Turkey | United States |
| -- | -------------- | ------ | ------------- |
| 1  | GB             |        |               |
| 2  |                | TR     |               |
| 3  |                |        | US            |

-> Transformed all the columns in the datatable, from long to wide, using `code` as `key column name` and `country` as the `value column name.`
