diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 0b4e83f13ac51..e668069760574 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -486,7 +486,10 @@ def _is_label_like(key): def _is_list_like(obj): - return np.iterable(obj) and not isinstance(obj, basestring) + # Consider namedtuples to be not list like as they are useful as indices + return (np.iterable(obj) + and not isinstance(obj, basestring) + and not (isinstance(obj, tuple) and type(obj) is not tuple)) def _need_slice(obj): diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index 9d77dc0f65a07..9daeaec3c4422 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -5122,7 +5122,6 @@ def test_stale_cached_series_bug_473(self): def test_index_namedtuple(self): # Skipping until 1026 is properly resolved - raise nose.SkipTest from collections import namedtuple IndexType = namedtuple("IndexType", ["a", "b"]) idx1 = IndexType("foo", "bar")