File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,17 @@ def rename(
437
437
* ,
438
438
inplace : bool = False ,
439
439
) -> Optional [Index ]:
440
- names = [name ] if isinstance (name , blocks .Label ) else list (name )
440
+ # Tuples are allowed as a label, but we specifically exclude them here.
441
+ # This is because tuples are hashable, but we want to treat them as a
442
+ # sequence. If name is iterable, we want to assume we're working with a
443
+ # MultiIndex. Unfortunately, strings are iterable and we don't want a
444
+ # list of all the characters, so specifically exclude the non-tuple
445
+ # hashables.
446
+ if isinstance (name , blocks .Label ) and not isinstance (name , tuple ):
447
+ names = [name ]
448
+ else :
449
+ names = list (name )
450
+
441
451
if len (names ) != self .nlevels :
442
452
raise ValueError ("'name' must be same length as levels" )
443
453
You can’t perform that action at this time.
0 commit comments