Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe unstack

index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'), ('two', 'a'), ('two', 'b')])
>>> s = pd.Series(np.arange(1.0, 5.0), index=index)
>>> s
one  a   1.0
     b   2.0
two  a   3.0
     b   4.0
dtype: float64

>>> s.unstack(level=0)
   one  two
a  1.0   3.0
b  2.0   4.0
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #dataframe #unstack
ADD COMMENT
Topic
Name
7+1 =