Skip to content

Commit 7627e93

Browse files
committed
Only check against Iterable in is_list_like and add test for str
1 parent 08c0b26 commit 7627e93

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

doc/source/whatsnew/v0.21.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ Indexing
517517
- Bug in ``CategoricalIndex`` reindexing in which specified indices containing duplicates were not being respected (:issue:`17323`)
518518
- Bug in intersection of ``RangeIndex`` with negative step (:issue:`17296`)
519519
- Bug in ``IntervalIndex`` where performing a scalar lookup fails for included right endpoints of non-overlapping monotonic decreasing indexes (:issue:`16417`, :issue:`17271`)
520-
- Bug in ``Series.rename`` when called with a `callable` alters name of series rather than index of series. (:issue:`17407`)
520+
- 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`)
521521

522522
I/O
523523
^^^

pandas/core/dtypes/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def is_list_like(obj):
263263
False
264264
"""
265265

266-
return (hasattr(obj, '__iter__') and isinstance(obj, Iterable) and
266+
return (isinstance(obj, Iterable) and
267267
not isinstance(obj, string_and_binary_types))
268268

269269

pandas/tests/dtypes/test_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __getitem__(self):
5858
def test_is_list_like():
5959
passes = ([], [1], (1, ), (1, 2), {'a': 1}, set([1, 'a']), Series([1]),
6060
Series([]), Series(['a']).str)
61-
fails = (1, '2', object())
61+
fails = (1, '2', object(), str)
6262

6363
for p in passes:
6464
assert inference.is_list_like(p)

0 commit comments

Comments
 (0)