MulSeries.reset_index#

MulSeries.reset_index(columns=None, drop=False, inplace=False, col_fill='')#

Reset the columns of the index dataframe as the columns of the mulseries.

Parameters#

columnscolumn name(s) of the index dataframe.

If this argument is None, reset the index of the index dataframe. If the name of this index is None, it will be named as “primary_index”. If “primary_index” exists in the primary columns, it will be named as “primary_index_1” and so on.

dropbool, default False

Just reset the index, without inserting index dataframe’s column(s) as column(s) in the new MulDataFrame.

inplacebool, default False

Modify the MulSeries in place (do not create a new object).

col_fillobject, default ‘’

A scalar, a pandas Series or a pandas DataFrame to fill in the columns dataframe of the new MulDataFrame for the inserted values. If the argument is a Series or a DataFrame, its index should align with the index of the mulseries’ name (which is a pandas series) in the same way as the align mode in the constructor.

Returns#

MulSeries, MulDataFrame or None

The return value behaves similarly to Series.reset_index.

Examples#

>>> import muldataframe as md
>>> index = pd.DataFrame([[1,2],[3,6],[5,6]],
             index=['a','b','b'],
             columns=['x','y'])
>>> name = pd.Series([5,7],
                index=['f','g'], name='c')
>>> ms = MulSeries([1,8,9],index=index,name=name)
>>> ms.reset_index()
(3, 2)    g                7
          f                5
            primary_index  c
--------  --------------------
   x  y     primary_index  c
0  1  2   0             a  1
1  3  6   1             b  8
2  5  6   2             b  9

Add a col_fill:

>>> ss_fill = pd.Series([8,9],index=['g','f'],name='primary_index'))
>>> ms.reset_index(col_fill=ss_fill)
(3, 2)    g             8  7
          f             9  5
            primary_index  c
--------  ---------------------
   x  y     primary_index  c
0  1  2   0             a  1
1  3  6   1             b  8
2  5  6   2             b  9