Description
Is your feature request related to a problem?
Yes, this would improve predictability of behavior with pandas extension arrays.
Describe the solution you'd like
pandas.api.types.is_list_like
can check for iterability in a more pythonic way according to https://docs.python.org/3/glossary.html#term-iterable. This would result in the appropriate call being iter(obj)
rather than checking for __iter__
attribute.
API breaking implications
This will not affect the API.
Describe alternatives you've considered
Alternative solutions include communicating to third parties that they must change their extension arrays to include hasattr(q, "__iter__") == False
to make sure that classes with ambiguous data iterability (may contain either scalar or array-like data) are perceived as utterable when they contain scalar data.
Additional context
Opened a bug report for this issue. I think an enhancement request is more appropriate, but I am linking the previous (closed) bug report as it includes useful information.
#43195