Skip to content
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

CLN: pass drop=None to DataFrame.set_geometry #3255

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

martinfleis
Copy link
Member

A small follow-up on #3237 to be consistent with our own new default and don't warn when user does DataFrame.set_geometry(geoms).

This also gets emitted in explode with no way of silencing.

import geopandas as gpd
from geodatasets import get_path

df = gpd.read_file(get_path('nybb'))
df.explode()
/Users/martin/Git/geopandas/geopandas/geodataframe.py:2469: FutureWarning: The `drop` keyword argument is deprecated and in future the only supported behaviour will match drop=False. To silence this warning and adopt the future behaviour, stop providing `drop` as a keyword to `set_geometry`. To replicate the `drop=True` behaviour you should update your code to
`geo_col_name = gdf.active_geometry_name; gdf.set_geometry(new_geo_col).drop(columns=geo_col_name).rename_geometry(geo_col_name)`.
  return gf.set_geometry(col, drop=drop, inplace=False, crs=crs)

@m-richards
Copy link
Member

This also gets emitted in explode with no way of silencing.

We should do the same change and pass drop=None inside explode then I would think - since in the past this always was drop=False, and in future it will continue to behave as drop=False?

@m-richards m-richards changed the title pass drop=None to DataFrame.set_geometry CLN: pass drop=None to DataFrame.set_geometry Apr 18, 2024
@martinfleis
Copy link
Member Author

We should do the same change and pass drop=None inside explode

That uses the default. Do you think we need to be explicit there?

@m-richards
Copy link
Member

We should do the same change and pass drop=None inside explode

That uses the default. Do you think we need to be explicit there?

Ah sorry, confused myself, should be drop=False, no reason to have a warning in that case I think

@m-richards m-richards merged commit d6459fc into geopandas:main Apr 18, 2024
20 checks passed
@martinfleis martinfleis deleted the set-geometry-warning branch April 19, 2024 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants