You are viewing documentation about an older version (1.21.0). View latest version

modin.pandas.Series.unstack¶

Series.unstack(level: int | str | list = - 1, fill_value: int | str | dict = None, sort: bool = True)[source]¶

Unstack, also known as pivot, Series with MultiIndex to produce DataFrame.

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:

Snowpark pandas DataFrame

Notes

Supports only integer level and sort = True. Internally, calls pivot_table or melt to perform unstack operation.

Examples

>>> s = pd.Series([1, 2, 3, 4],
...               index=pd.MultiIndex.from_product([['one', 'two'],
...                                                 ['a', 'b']]))
>>> s
one  a    1
     b    2
two  a    3
     b    4
dtype: int64
>>> s.unstack(level=-1)
     a  b
one  1  2
two  3  4
>>> s.unstack(level=0)
   one  two
a    1    3
b    2    4
Copy