s = pd.Series([0], index=pd.MultiIndex.from_tuples([('a', 1)]))
# This works:
s.rename(lambda x: x)
# This fails:
s.iloc[0:0].rename(lambda x: x)
Renaming an empty index should not throw an error. It should just return the original empty index. It appears to be failing because _transform_index
calls MultiIndex.from_tuples
, which doesn't accept an empty list of tuples.
I would imagine that this could instead call from_arrays
, which from_tuples
calls anyway, or it could check for the special case of an empty index.
Comment From: jreback
this is a special case duplicate of #4160; renaming of a MI is not tested much at all and the implementation needs fixing. PR's are welcome (#13766 is a start of one).