Skip to content

Commit e893ef7

Browse files
committed
Update to use numpy iterable
1 parent 57fa02f commit e893ef7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pandas/_libs/lib.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,9 @@ def is_list_like(obj: object, allow_sets: bool = True) -> bool:
991991

992992
cdef inline bint c_is_list_like(object obj, bint allow_sets) except -1:
993993
return (
994-
isinstance(obj, abc.Iterable)
994+
np.iterable(obj)
995995
# we do not count strings/unicode/bytes as list-like
996996
and not isinstance(obj, (str, bytes))
997-
# assume not a 0d array unless there's evidence otherwise
998-
and getattr(obj, "ndim", 1) != 0
999997
# exclude sets if allow_sets is False
1000998
and not (allow_sets is False and isinstance(obj, abc.Set))
1001999
)

pandas/tests/dtypes/test_inference.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ def __init__(self, values):
7575
self._values = values
7676

7777
def __iter__(self):
78-
for element in iter(self._values):
79-
yield element
78+
iter_values = iter(self._values)
79+
80+
def it_outer():
81+
for element in iter_values:
82+
yield element
83+
84+
return it_outer()
8085

8186
@property
8287
def ndim(self):

0 commit comments

Comments
 (0)