Description
The name of the function is_list_like
from pandas.core.dtypes.common
suggests that whatever gets True
returned will be "like a list". As such, it's used in a handful of places - e.g. I got asked to use it in #20347, and now again in #22486. What I found out in the latter one is that it's true for sets:
>>> from pandas.core.dtypes.common import is_list_like
>>> is_list_like({1, 2, 3})
True
This has some uncomfortable consequences - for str.cat
it's a bug (#23009), and for df.set_index
it would be too.
@jreback asked me to try out removing set
from is_list_like
(#22486 (comment)), so this issue is following up on that.
@h-vetinari why don't you try (separate PR) excluding set from is_list_like and see what the implications of that are.
There are some rare cases like .isin
, where sets should also be included. I'd say to have a looser definition is_set_like
that's basically is_list_like or set
. Alternatively, one could think of is_list_like(strict=False)
to include sets.
Another question is if this needs a deprecation cycle and how?