Skip to content

Commit 45f9232

Browse files
committed
do not consider tuples single labels in rename
1 parent 1c843ed commit 45f9232

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bigframes/core/indexes/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,17 @@ def rename(
437437
*,
438438
inplace: bool = False,
439439
) -> 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+
441451
if len(names) != self.nlevels:
442452
raise ValueError("'name' must be same length as levels")
443453

0 commit comments

Comments
 (0)