-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: assigning scalar with a length no longer works #26333
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
There are several potential issues with assigning list-like values, see eg the issues being linked to here: #19590 (comment) Probably caused by #20732 |
I am getting the same issue as the multipolygon seen as equivalent to a list of polygons.
Hope that's helpful to someone. |
Hi! Any solution in sight? Also encountering the issue when wanting to assign MultiPolygons and the list work-around as well as ".values" work-around do not seem to help... Thankful for any hint! |
@jklatt I was able to resolve by roundtripping a shapely geo through geopandas:
This seems to avoid the |
Works like a charm! Thank you Thomas :) |
Thanks, @koshy1123 ! Your roundtripping shapely geo via geopandas worked for me! |
I've tried various version of the workaround for this problem, but I still can't get anything to work. What should work:
Some workarounds attempted:
All give
or
Is there any updated solution or working workaround? |
@bramson I think the one that worked for me is not in your list:
😞 |
I am having the same issue as well. So far the only solution for me was to build a complex |
I found that if the geopandas DataFrame contains only a geometry column the problem goes away. As soon as an additional column has values the above issue arises. So my solution was to split the data into two Dataframes whilst populating geometry, one with only geometry and a second with additional data (using the same indexes). Then combine the two dataframes afterwards. Not ideal, but a work around if you are struggling. |
Assigning a value to a single location in a DataFrame (using
.loc
with scalar indexers) started to fail with "values with a length".Consider the following example:
This raises on 0.23.4 - master, but worked in 0.20.3 - 0.22.0 (the ones I tested):
Related to #25806
We don't have very robust support in general for list-like values, but, for the specific case above of updating a single value, I don't think there is anything ambiguous about it? You are updating a single value, so the passed value should simply be put in that place?
Note, the above is with tuples. But, there are also custom objects like MultiPolygons that represent single objects, but do define a
__len__
..The text was updated successfully, but these errors were encountered: