---
title: Data Reshape
description: Convert data between Wide and Long formats. Use Wide to Long (unpivot) to collapse multiple columns into one, or Long to Wide (pivot) to expand Long format data into columns.
priority: 0.6
---

# Data Reshape {#data-reshape}

Convert data between Wide format and Long format. Use this to restructure data layouts to match the requirements of different analysis methods.

## Basic Usage {#basic-usage}

### Opening Reshape {#opening-reshape}

Select **Data > Reshape (Wide/Long)...** from the menu bar to open a new Reshape tab.

![Reshape tab basic view](../shared/images/reshape-basic.webp)

The screen consists of a settings panel on the left and a preview area on the right. Switch between **Wide to Long** and **Long to Wide** using the tabs at the top of the settings panel.

## Sample Data Used in This Page {#sample-data-used-in-this-page}

The examples on this page use a grades dataset ([grades.csv](../shared/files/reshape-grades.csv)) containing test scores for 5 students. Each subject has its own column in Wide format.

| name  | math | science | english |
|-------|------|---------|---------|
| Alice | 90   | 85      | 88      |
| Bob   | 75   | 92      | 80      |
| Carol | 88   | 78      | 95      |
| Dave  | 92   | 88      | 82      |
| Eve   | 78   | 95      | 90      |

## Wide to Long {#wide-to-long}

Collapse multiple columns into a single column (unpivot). Each row expands into multiple rows.

For example, convert the grades data above into a "one row per subject" format. The result looks like this:

| name  | subject | score |
|-------|---------|-------|
| Alice | math    | 90    |
| Alice | science | 85    |
| Alice | english | 88    |
| Bob   | math    | 75    |
| ...   | ...     | ...   |

This example sets Variable Column Name to `subject` and Value Column Name to `score`. Running with the defaults produces columns named `variable` and `value`.

### Parameters {#parameters}

**Dataset** - Select the dataset to transform.

**ID Columns (keep as-is)** - Select columns to preserve through the transformation. These values are repeated in each expanded row. In the example above, `name` is the ID column. Optional. If omitted, the result contains only the Variable and Value columns.

**Value Columns (to unpivot)** - Select columns to unpivot. In the example above, `math`, `science`, and `english`. At least one column is required.

**Variable Column Name** - Name for the new column that holds the original column names. Defaults to `variable`.

**Value Column Name** - Name for the new column that holds the values. Defaults to `value`.

Click **Preview** to see the result.

![Wide to Long conversion preview](../shared/images/reshape-wide-to-long.webp)

## Long to Wide {#long-to-wide}

Convert Long format data to Wide format (pivot). Multiple rows are collapsed into a single row.

Use this for the reverse of Wide to Long, or to arrange aggregated results into a tabular layout.

For example, convert the Wide to Long result above back to Wide format.

Input data in Long format:

| name  | subject | score |
|-------|---------|-------|
| Alice | math    | 90    |
| Alice | science | 85    |
| Alice | english | 88    |
| Bob   | math    | 75    |
| ...   | ...     | ...   |

Set Variable Column to `subject` and Value Column to `score`. The unique values in `subject` (math, science, english) each become a new column.

Result:

| name  | math | science | english |
|-------|------|---------|---------|
| Alice | 90   | 85      | 88      |
| Bob   | 75   | 92      | 80      |
| ...   | ...  | ...     | ...     |

### Parameters {#parameters-1}

**Dataset** - Select the dataset to transform.

**ID Columns (row identifiers)** - Select columns to preserve through the transformation. Rows with the same ID values are collapsed into a single row. In the example above, `name` is the ID column. Select columns that identify which group each row belongs to.

**Variable Column (column names)** - Select one column whose unique values become new column names. In the example above, `subject` is the Variable Column.

**Value Column (cell values)** - Select one column whose values fill the new columns. In the example above, `score` is the Value Column.

Any column not assigned to ID Columns, Variable Column, or Value Column is not included in the result. To keep auxiliary columns such as grouping variables, add them to ID Columns.

![Long to Wide conversion preview](../shared/images/reshape-long-to-wide.webp)

## Preview and Save {#preview-and-save}

Click **Preview** to check the result. The preview shows up to 100 rows along with the total row and column counts.

When the result looks correct, click **Save as Dataset**. Enter a dataset name and save to create a new derived dataset.

## Notes {#notes}

- In Wide to Long, if Value Columns have different data types, the resulting value column type depends on the combination. A mix of int64 and float64 is promoted to float64, and a mix of date and datetime is promoted to datetime. Any other combination, such as numeric and string columns, is converted to string type. When all selected columns share the same type, that type is preserved
- In Long to Wide, duplicate combinations of ID columns and variable column cause an error. To resolve duplicates, aggregate the data in [SQL Editor](sql-editor) beforehand, or add columns to ID Columns that uniquely identify each row
- In Long to Wide, missing combinations result in null values

## See also {#see-also}

- **[Datasets](datasets)** - Differences between Primary and Derived Datasets
- **[Data Processing with SQL Editor](sql-editor)** - Advanced data transformation with SQL
- **[Data Table](data-table)** - Viewing and manipulating data
