pandas.Series.reset_index¶
- 
Series.reset_index(level=None, drop=False, name=None, inplace=False)[source]¶
- Analogous to the - pandas.DataFrame.reset_index()function, see docstring there.- Parameters: - level : int, str, tuple, or list, default None - Only remove the given levels from the index. Removes all levels by default - drop : boolean, default False - Do not try to insert index into dataframe columns - name : object, default None - The name of the column corresponding to the Series values - inplace : boolean, default False - Modify the Series in place (do not create a new object) - Returns: - resetted : DataFrame, or Series if drop == True - Examples - >>> s = pd.Series([1, 2, 3, 4], index=pd.Index(['a', 'b', 'c', 'd'], ... name = 'idx')) >>> s.reset_index() index 0 0 0 1 1 1 2 2 2 3 3 3 4 - >>> arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo', ... 'foo', 'qux', 'qux']), ... np.array(['one', 'two', 'one', 'two', 'one', 'two', ... 'one', 'two'])] >>> s2 = pd.Series( ... np.random.randn(8), ... index=pd.MultiIndex.from_arrays(arrays, ... names=['a', 'b'])) >>> s2.reset_index(level='a') a 0 b one bar -0.286320 two bar -0.587934 one baz 0.710491 two baz -1.429006 one foo 0.790700 two foo 0.824863 one qux -0.718963 two qux -0.055028