Closed
Description
At least I think this is a bug. #4627 was meant to unify the Series and DataFrame.rename APIs right?
In [35]: idx = pd.MultiIndex.from_tuples([(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)])
In [36]: s = pd.Series(np.arange(6), index=idx)
In [37]: s
Out[37]:
1 1 0
2 1
3 2
2 1 3
2 4
3 5
dtype: int64
In [38]: s.index.names = ['outer', 'inner']
In [39]: s.rena
s.rename s.rename_axis
In [39]: s.rename({1: 'L1', 2: 'L2', 3: 'L3'}, level='inner')
Out[39]:
outer inner
L1 L1 0
L2 1
L3 2
L2 L1 3
L2 4
L3 5
dtype: int64
Edit: I guess I'm a bit confused because the docstring seems to indicate that Series.rename() does something a bit different:
Conform Series to new index with optional filling logic, placing
NA/NaN in locations having no value in the previous index. A new object
is produced unless the new index is equivalent to the current one and
copy=False
Metadata
Metadata
Assignees
Labels
No labels