Skip to content

Commit dfe9d4a

Browse files
philngojorisvandenbossche
authored andcommitted
DOC: fix Series.reset_index example (pandas-dev#19930)
1 parent 9bdc5c8 commit dfe9d4a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

pandas/core/series.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -1021,31 +1021,31 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):
10211021
>>> s = pd.Series([1, 2, 3, 4], index=pd.Index(['a', 'b', 'c', 'd'],
10221022
... name = 'idx'))
10231023
>>> s.reset_index()
1024-
idx 0
1025-
0 0 1
1026-
1 1 2
1027-
2 2 3
1028-
3 3 4
1024+
idx 0
1025+
0 a 1
1026+
1 b 2
1027+
2 c 3
1028+
3 d 4
10291029
10301030
>>> arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo',
10311031
... 'foo', 'qux', 'qux']),
10321032
... np.array(['one', 'two', 'one', 'two', 'one', 'two',
10331033
... 'one', 'two'])]
10341034
>>> s2 = pd.Series(
1035-
... np.random.randn(8),
1035+
... range(8),
10361036
... index=pd.MultiIndex.from_arrays(arrays,
10371037
... names=['a', 'b']))
10381038
>>> s2.reset_index(level='a')
1039-
a 0
1039+
a 0
10401040
b
1041-
one bar -0.286320
1042-
two bar -0.587934
1043-
one baz 0.710491
1044-
two baz -1.429006
1045-
one foo 0.790700
1046-
two foo 0.824863
1047-
one qux -0.718963
1048-
two qux -0.055028
1041+
one bar 0
1042+
two bar 1
1043+
one baz 2
1044+
two baz 3
1045+
one foo 4
1046+
two foo 5
1047+
one qux 6
1048+
two qux 7
10491049
"""
10501050
inplace = validate_bool_kwarg(inplace, 'inplace')
10511051
if drop:

0 commit comments

Comments
 (0)