modin.pandas.Series.unstack¶
- Series.unstack(level: int | str | list = - 1, fill_value: int | str | dict = None, sort: bool = True)[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/series_overrides.py#L1614-L1639)¶
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
andsort = True
. Internally, callspivot_table
ormelt
to performunstack
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