Inconsistent behaviour of rename for MultiIndexed DataFrames and Series (original) (raw)
If I try to rename a MultiIndexed DataFrame, everything works correctly:
In [3]: pd.DataFrame([11,21,31], index=pd.MultiIndex.from_tuples([("A",x) for x in ["a","B","c"]])).rename(str.lower) Out[3]: 0 a a 11 b 21 c 31
But if I do the same thing with the Series, it doesn't work:
In [4]: pd.Series([11,21,31], index=pd.MultiIndex.from_tuples([("A",x) for x in ["a","B","c"]])).rename(str.lower)
TypeError Traceback (most recent call last) in () ----> 1 pd.Series([11,21,31],index=pd.MultiIndex.from_tuples([("A",x) for x in ["a","B","c"]])).rename(str.lower)
/home/viktor/pandas/pandas/core/series.py in rename(self, mapper, inplace) 3187 result = self if inplace else self.copy() 3188 result.index = Index([mapper_f(x) -> 3189 for x in self.index], name=self.index.name) 3190 3191 if not inplace:
TypeError: descriptor 'lower' requires a 'str' object but received a 'tuple'
This behavior is observed in 0.12 and in the master branch.