-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: when to cast list-like to ndarray, check len match #27911
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
Comments
I think the main use case where this comes up is having scalar values that are considered "list like" (according to our The obvious case is having lists or tuples in a Series:
But note that it is more than those built-in containers. When working with custom Python objects, your scalar object needs to be iterable to be seen list-like (so either have One example that I work with myself of an "iterable scalar" are Shapely geometry objects. One can always argue about the design, but eg their "MultiPolygon" object (a single geometrical object that is built up from multiple polygons) is iterable. At the moment, this is only relevant for object dtype though, I think none of the other dtypes share the above concern. And for those a consistent flow of what checks / conversions are done seems like a good idea. |
@jorisvandenbossche thanks for weighing in here. Will For the object-dtype case, should we continue special-casing list or not-check it like we do for other listlikes? |
Do you mean on the scalar "container-like" objects? (and also not sure what you expect to be "correct")
It probably makes sense to make the handling of list or non-array-list-likes uniform. |
xref #27873
In many arithmetic/comparison ops we do something like
but we are not entirely consistent about this (see below for summary of what we do where). AFAICT the only case where we wouldn't want to do both of these consistently is if we have an object-dtype, the relevant test case being something like:
(note in this example ATM
ser == ser[0]
will raiseValueError
).We should be consistent in what we are doing for these, but need to decide what that consistent behavior should be.
Summary of current behavior:
Not yet reviewed: IntegerArray, PandasArray, SparseArray, Index, FooIndex
The text was updated successfully, but these errors were encountered: