# Pivot Table

## Pivot table, powered by SQL.

### Required Inputs

* Values: a dictionary of the column with values you want to aggregate & the method of aggregation for your values

### Optional Inputs

* Rows: column(s) to group by down
* Columns: column(s) to pivot across
* Filters: filters to apply

### Notes

* Applies a hard limit of 500 distinct values in the 'columns' column

## Parameters

| Name    | Type              | Description                                          | Is Optional |
| ------- | ----------------- | ---------------------------------------------------- | ----------- |
| values  | column\_agg\_list | columns to aggregate                                 |             |
| rows    | column\_list      | Columns to group by (column values will become rows) | True        |
| columns | column            | column with row values that will become columns      | True        |
| filters | filter\_list      | Filters to apply to the table                        | True        |

## Example

```python
ds2 = ds.pivot_table(
  rows=['DATE'],
  values={
      'CLOSE': ['SUM', 'AVG'],
      'OPEN': ['SUM', 'AVG']
  },
  columns='SYMBOL',
)
ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/pivot_table/snowflake/pivot_table.sql>" %}


---

# 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.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/pivot_table.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.
