# Long to Wide with pivot

pivot turns a long table back into a wide one, with index naming the rows, columns naming the column headers and values filling the cells, stops with an error when two rows would land in the same cell, and pivot_table, which combines those rows instead, is the right choice only when combining them is what you meant.

![Cheat sheet: Long to Wide with pivot](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/930dbf8ecc4949ceb240181e4f22c7c7.webp)

- Category: Data Analysis
- Level: Journeyman
- Tags: Long Format, Pivot, Pivot Table, python, Wide Format
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-pivot-cheat-sheet
