`deepcopy` doesn't deepcopy `.attrs['transform']` in `GeoDataFrame`
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
This fails:
import geopandas as gpd
from shapely.geometry import Point
import copy
# Create a GeoDataFrame
gdf = gpd.GeoDataFrame({
'geometry': [Point(1, 1), Point(2, 2)],
'value': [1, 2]
})
# Add an attribute to the GeoDataFrame
gdf.attrs['transform'] = {}
# Copy the GeoDataFrame
gdf2 = copy.deepcopy(gdf)
# Print the IDs
print(id(gdf.attrs['transform'])) # ID of copied attribute
print(id(gdf2.attrs['transform'])) # ID of original attribute
# Assertion
assert gdf.attrs['transform'] is not gdf2.attrs['transform']
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by running the provided GeoDataFrame and deepcopy reproduction, then trace how GeoDataFrame.attrs is copied. Done means the transform attribute in the copied GeoDataFrame is a distinct object while preserving its contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100