Skip to content

Commit

Permalink
Prevent tuple sublcass instances from being recognized as "list-like".
Browse files Browse the repository at this point in the history
Close #1026
  • Loading branch information
Eric Chlebek committed Apr 17, 2012
1 parent a79f4d6 commit de427aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit de427aa

Please sign in to comment.