bigframes.pandas.DataFrame.unstack#
- DataFrame.unstack(level: Hashable | Sequence[Hashable] = -1)[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).
Examples:
>>> df = bpd.DataFrame({'A': [1, 3], 'B': [2, 4]}, index=['foo', 'bar']) >>> df A B foo 1 2 bar 3 4 [2 rows x 2 columns]
>>> df.unstack() A foo 1 bar 3 B foo 2 bar 4 dtype: Int64