modin.pandas.DataFrame.unstack¶
- DataFrame.unstack(level=- 1, fill_value=None, sort=True) Union[DataFrame, Series][source]¶
Pivot a level of the (necessarily hierarchical) index labels.
Returns a DataFrame having a new level of column labels whose inner-most level consists of the pivoted index labels.
If the index is not a MultiIndex, the output will be a Series (the analogue of stack when the columns are not a MultiIndex).
- Parameters:
level (int, str, list, default -1) – Level(s) of index to unstack, can pass level name.
fillna (int, str, dict, optional) – Replace NaN with this value if the unstack produces missing values.
sort (bool, default True) – Sort the level(s) in the resulting MultiIndex columns.
- Return type:
Notes
Supports only integer
levelandsort = True. Internally, callspivot_tableormeltto perform unstack operation.See also
DataFrame.pivotPivot without aggregation that can handle non-numeric data.
DataFrame.stackPivot a level of the column labels (inverse operation from unstack).
Examples