pandas.pivot
pandas 3.1.1 · General functions · function
Move distinct values into columns. Each output row–column pair needs a single source value.
Call syntax
pd.pivot(data, *, columns, index=…, values=…)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
data |
Required Positional or keyword |
DataFrame Provide the input data read, transformed, or stored by this call. |
columns |
Required Keyword only |
Hashable or a sequence of the previous Supply column labels or control how columns are handled. |
index |
Optional Keyword only |
Hashable or a sequence of the previous Supply row labels or control how existing row labels are used. |
values |
Optional Keyword only |
Hashable or a sequence of the previous Supply values to transform, match, aggregate, or use as data. |
Returns
DataFrame