# Pivot

The Pivot step allows to transform rows into columns. It is the reverse operation of an `unpivot` step.

Pivoting a column into several columns means that every unique label found in that column becomes a column header. The column gets pivoted “around” fixed columns that you can specify. You also need to specify a value column where values will be found to fill pivoted columns. If aggregation needs to be performed, you can choose the aggregation function (`sum` by default).

### Step parameters

* `Keep columns...`: the columns to remain fixed, around which the pivot will occur
* `Pivot column...`: the column to be pivoted
* `Use values in...`: the columns where values are found to fill the pivoted columns
* `Aggregate values using...`: the aggregation function to be used when aggregation has to be performed

### Example

**Input**

<figure><img src="/files/3POC71s1hEFlMD0OgcSA" alt=""><figcaption><p>Reshape - pivot input</p></figcaption></figure>

**Configuration**

```json
{
    "index": ["Label"],
    "column_to_pivot": "Country",
    "value_column": "Value", 
    "aggfunction": "sum"
}
```

**Output**

<figure><img src="/files/HQXuA7UJMorWCuvqGIfw" alt=""><figcaption><p>Reshape - pivot output</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-v3.toucantoco.com/data-management-in-datahub/datasets-in-toucan/preparing-data/overview-of-youprep-tm/reshape/pivot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
