10000 BUG: Do not modify original DataFrame during creation of GeoDataFrame by Sangarshanan · Pull Request #1324 · geopandas/geopandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: Do not modify original DataFrame during creation of GeoDataFrame #1324

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

Closed
wants to merge 4 commits into from

Conversation

Sangarshanan
Copy link
Contributor
@Sangarshanan Sangarshanan commented Mar 12, 2020

Fixes #1179
Make modification to the copy of the data instead of the original,

@martinfleis
Copy link
Member

Thanks, this seems to do the trick. I am not sure if there would not be some memory related consequences somewhere, but hopefully not. Can you add a test for this? You can just easily use than snippet from the issue and assert_frame_equal or something to check than before and after df is the same and than gdf is correctly created.

I'll check failing CI, but it is not related.

Co-Authored-By: Martin Fleischmann <martin@martinfleischmann.net>
Copy link
Member
@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sangarshanan Thanks for looking at this!

This clearly fixes the original (and buggy!) case, which is nice.
I am only wondering what the consequences are for other cases. For example, in pandas, creating a dataframe from a dataframe does not copy. Similarly, right now, GeoDataFrame(gdf) also does not create a copy (I need to think a bit more about this ..).

Also related to pandas-dev/pandas#29309

@martinfleis martinfleis changed the title Create a copy of original dataframe BUG: Do not modify original DataFrame during creation of GeoDataFrame Mar 27, 2020
@martinfleis martinfleis added this to the 0.7.1 milestone Mar 27, 2020
@martinfleis martinfleis mentioned this pull request May 19, 2020
25 tasks
@martinfleis martinfleis modified the milestones: 0.7.1, 0.8.0 May 21, 2020
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.8.0, 0.9.0 Jun 24, 2020
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.9.0, 0.10 Feb 27, 2021
@brl0
Copy link
brl0 commented Jul 23, 2021

This may be related to or affected by pandas-dev/pandas#38939. I think I like having the option of making a copy of the original dataframe or not.

@martinfleis
Copy link
Member

I will close this in favour of #2306, that implements a bit smarter solution. We can continue our discussion there. Thanks for looking into that @Sangarshanan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creation of geodataframe shouldn't modify the original dataframe
4 participants
0