Data Wrangling & Pipelines

Pivot / Reshape

Pivoting (reshaping) is transforming a table between long and wide shapes without changing the underlying facts. Pivoting wider spreads one column's categories into new columns; pivoting longer gathers many columns back into key-value rows.

Reshaping is one of the most-used wrangling moves because the “right” shape depends entirely on your next step: long to feed a chart, wide to make a human-readable summary. A spreadsheet PivotTable is the same idea bundled with aggregation — it reshapes and summarizes at once.

Also called
reshapepivotmelt and cast