Skip to content

Commit

Permalink
Only check against Iterable in is_list_like and add test for str
Browse files Browse the repository at this point in the history
  • Loading branch information
huashuai committed Sep 29, 2017
1 parent f97c9bc commit 45d30d4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,11 @@ Indexing
- Bug in ``CategoricalIndex`` reindexing in which specified indices containing duplicates were not being respected (:issue:`17323`)
- Bug in intersection of ``RangeIndex`` with negative step (:issue:`17296`)
- Bug in ``IntervalIndex`` where performing a scalar lookup fails for included right endpoints of non-overlapping monotonic decreasing indexes (:issue:`16417`, :issue:`17271`)
<<<<<<< f97c9bc2d44f7aa58314fe67f1fa074af3032473
<<<<<<< 4996e764fb0adbd5c77574eb3cb60f19c0fafba3
<<<<<<< 99300ddcc636c859a02b3010ee379d1adbd1678e
- Bug in :meth:`DataFrame.first_valid_index` and :meth:`DataFrame.last_valid_index` when no valid entry (:issue:`17400`)
- Bug in ``Series.rename`` when called with a `callable` alters name of series rather than index of series. (:issue:`17407`)
- Bug in :func:`Series.rename` when called with a `callable`, incorrectly alters the name of the `Series`, rather than the name of the `Index`. (:issue:`17407`)

I/O
^^^
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def is_list_like(obj):
False
"""

return (hasattr(obj, '__iter__') and isinstance(obj, Iterable) and
return (isinstance(obj, Iterable) and
not isinstance(obj, string_and_binary_types))


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __getitem__(self):
def test_is_list_like():
passes = ([], [1], (1, ), (1, 2), {'a': 1}, set([1, 'a']), Series([1]),
Series([]), Series(['a']).str)
fails = (1, '2', object())
fails = (1, '2', object(), str)

for p in passes:
assert inference.is_list_like(p)
Expand Down

0 comments on commit 45d30d4

Please sign in to comment.