> For the complete documentation index, see [llms.txt](https://docs.rasgoml.com/rasgo-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/pivot_table.md).

# 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>" %}
