Skip to content

Commit ca94b7d

Browse files
committed
ENH: GH35131 Implement fix which allows numpy-like handling
Now pd.core.dtypes.inference.is_list_like correctly identifies numpy-like scalars as not being iterable
1 parent dcf6b66 commit ca94b7d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/_libs/lib.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,8 @@ cdef inline bint c_is_list_like(object obj, bint allow_sets) except -1:
994994
isinstance(obj, abc.Iterable)
995995
# we do not count strings/unicode/bytes as list-like
996996
and not isinstance(obj, (str, bytes))
997-
# exclude zero-dimensional numpy arrays, effectively scalars
998-
and not (util.is_array(obj) and obj.ndim == 0)
997+
# exclude zero-dimensional duck arrays, effectively scalars
998+
and not (hasattr(obj, "ndim") and obj.ndim == 0)
999999
# exclude sets if allow_sets is False
10001000
and not (allow_sets is False and isinstance(obj, abc.Set))
10011001
)

0 commit comments

Comments
 (0)