w3resource

Pandas Series: unstack() function

Series-unstack() function

The unstack() function is used to reshape the data using stack() function in pandas converts the data into stacked format 

The level involved will automatically get sorted.

Syntax:

Series.unstack(self, level=-1, fill_value=None)
Pandas Series unstack image
Name Description Type/Default Value Required / Optional
level Level(s) to unstack, can pass level name. int, str, or list of these
Default Value: Last Level
Required
fill_value Value to use when replacing NaN values. scalar value
Default Value: None
Required

Returns: DataFrame - Unstacked Series.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts