@@ -3020,6 +3020,37 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
3020
3020
Returns
3021
3021
-------
3022
3022
resetted : DataFrame
3023
+
3024
+ Examples
3025
+ --------
3026
+ >>> df = pd.DataFrame({'a': [1, 2, 3, 4], 'b': [5, 6, 7, 8]},
3027
+ ... index=pd.Index(['a', 'b', 'c', 'd'],
3028
+ ... name='idx'))
3029
+ >>> df.reset_index()
3030
+ idx a b
3031
+ 0 a 1 5
3032
+ 1 b 2 6
3033
+ 2 c 3 7
3034
+ 3 d 4 8
3035
+ >>> arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo',
3036
+ ... 'foo', 'qux', 'qux']),
3037
+ ... np.array(['one', 'two', 'one', 'two', 'one', 'two',
3038
+ ... 'one', 'two'])]
3039
+ >>> df2 = pd.DataFrame(
3040
+ ... np.random.randn(8, 4),
3041
+ ... index=pd.MultiIndex.from_arrays(arrays,
3042
+ ... names=['a', 'b']))
3043
+ >>> df2.reset_index(level='a')
3044
+ a 0 1 2 3
3045
+ b
3046
+ one bar -1.099413 0.291838 0.598198 0.162181
3047
+ two bar -0.312184 -0.119904 0.250360 0.364378
3048
+ one baz 0.713596 -0.490636 0.074967 -0.297857
3049
+ two baz 0.998397 0.524499 -2.228976 0.901155
3050
+ one foo 0.923204 0.920695 1.264488 1.476921
3051
+ two foo -1.566922 0.783278 -0.073656 0.266027
3052
+ one qux -0.230470 0.109800 -1.383409 0.048421
3053
+ two qux -0.865993 -0.865984 0.705367 -0.170446
3023
3054
"""
3024
3055
inplace = validate_bool_kwarg (inplace , 'inplace' )
3025
3056
if inplace :
0 commit comments