Skip to content

Commit de427aa

Browse files
author
Eric Chlebek
committed
Prevent tuple sublcass instances from being recognized as "list-like".
Close #1026
1 parent a79f4d6 commit de427aa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandas/core/indexing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ def _is_label_like(key):
486486

487487

488488
def _is_list_like(obj):
489-
return np.iterable(obj) and not isinstance(obj, basestring)
489+
# Consider namedtuples to be not list like as they are useful as indices
490+
return (np.iterable(obj)
491+
and not isinstance(obj, basestring)
492+
and not (isinstance(obj, tuple) and type(obj) is not tuple))
490493

491494

492495
def _need_slice(obj):

pandas/tests/test_frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5122,7 +5122,6 @@ def test_stale_cached_series_bug_473(self):
51225122

51235123
def test_index_namedtuple(self):
51245124
# Skipping until 1026 is properly resolved
5125-
raise nose.SkipTest
51265125
from collections import namedtuple
51275126
IndexType = namedtuple("IndexType", ["a", "b"])
51285127
idx1 = IndexType("foo", "bar")

0 commit comments

Comments
 (0)