A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/../api/pandas.Series.unstack.html below:

pandas.Series.unstack — pandas 2.3.1 documentation

pandas.Series.unstack#
Series.unstack(level=-1, fill_value=None, sort=True)[source]#

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

Parameters:
levelint, str, or list of these, default last level

Level(s) to unstack, can pass level name.

fill_valuescalar value, default None

Value to use when replacing NaN values.

sortbool, default True

Sort the level(s) in the resulting MultiIndex columns.

Returns:
DataFrame

Unstacked Series.

Notes

Reference the user guide for more examples.

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4