# Pivot

Pivot columns into rows and columns. Values are count of pairs of rows and columns or aggregation of another column.

## How to Access This Feature

![](/files/-M4oNCewtH11gOQodqjl)

* Click "+" button and select "Pivot"

### From Column Menu

![](/files/-M4oNCf-zdufbXHGTPOF)

* You can also select "Pivot" from column menu of the column you want to pivot.

## Pivot

![](/files/-M4oNCf1eRakPUxtTfNJ)

1. `Rows` - select columns for Pivot Row.
2. `Columns` - select colums for Pivot Columns.
3. `Value` (Optional) - A column for values in output data frame.

### Parameters

* Remove NA - The default is TRUE. If NA should be removed from value.
* Fill NA with - The default is 0. This is what should be used for missing value in groups.

**Example**

*Original data:*

| clarity | certification | colour | price |
| ------- | ------------- | ------ | ----- |
| VVS2    | HRD           | F      | 10796 |
| VS1     | GIA           | F      | 1551  |
| VS1     | GIA           | F      | 4291  |
| VVS2    | GIA           | F      | 5881  |
| VS2     | GIA           | H      | 4585  |
| VVS2    | GIA           | H      | 5193  |

if you set **row**: clarify, colour **columns**: certification **value**: price **fill**:0

\
\&#xNAN;*it returns data frame with rows of combinations of clarity and colour and with columns of certification. Values are sum of price and missing values are filled by 0.*

| clarity\_colour | GIA  | HRD   |
| --------------- | ---- | ----- |
| VS1\_F          | 5842 | 0     |
| VS2\_H          | 4585 | 0     |
| VVS2\_F         | 5881 | 10796 |
| VVS2\_H         | 5193 | 0     |


---

# 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.exploratory.io/data-wrangling/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.
