bpd.Series.reset_index

Series.reset_index(*, drop=False)[source]

Reset the index.

This is useful when the index is meaningless and needs to be reset to the default before another operation.

Parameters:drop (bool, default False, keyword only) – When True, do not try to insert index into dataframe columns. This resets the index to the default integer index. If False, then turn input Series into DataFrame, adding original index as column.
Returns:When drop is False (the default), a DataFrame is returned. The newly created columns will come first in the DataFrame, followed by the original Series values. When drop is True, a Series is returned.
Return type:Series or DataFrame

Examples

>>> s = bpd.Series([6, 4, 3, 9, 5])
>>> sorted = s.sort_values()
>>> sorted.reset_index()
   index  0
0      2  3
1      1  4
2      4  5
3      0  6
4      3  9
>>> sorted.reset_index(drop=True)
0    3
1    4
2    5
3    6
4    9
dtype: int64