8000 ENH: make is_list_like handle non iterable numpy-like arrays correctly by znicholls · Pull Request #35127 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: make is_list_like handle non iterable numpy-like arrays correctly #35127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
Revert to relying on python's shortcircuit operators
Also avoid np.iterable
  • Loading branch information
znicholls committed Feb 13, 2021
commit 764e7b1045fa7ba9ffa587bdb54fac0e66f2f345
4 changes: 3 additions & 1 deletion pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ def is_list_like(obj: object, allow_sets: bool = True) -> bool:

cdef inline bint c_is_list_like(object obj, bint allow_sets) except -1:
return (
np.iterable(obj)
isinstance(obj, abc.Iterable)
# avoid numpy-style scalars
and not (hasattr(obj, "ndim") and obj.ndim == 0)
# we do not count strings/unicode/bytes as list-like
and not isinstance(obj, (str, bytes))
# exclude sets if allow_sets is False
Expand Down
0