Skip to content

REF: remove GeoDataFrame shim in _constructor_from_mgr#65175

Merged
jorisvandenbossche merged 2 commits intopandas-dev:mainfrom
jbrockmendel:ref-56681
Apr 15, 2026
Merged

REF: remove GeoDataFrame shim in _constructor_from_mgr#65175
jorisvandenbossche merged 2 commits intopandas-dev:mainfrom
jbrockmendel:ref-56681

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

@jbrockmendel jbrockmendel commented Apr 11, 2026

Summary

  • Remove dead GeoDataFrame name-check shim in DataFrame._constructor_from_mgr — geopandas has overridden _constructor_from_mgr directly since v0.14.3 (Jan 2024)
  • Remove _constructor_expanddim_from_mgr and inline its logic into Series.to_frame(), its only call site

Part of #56681.

Test plan

  • pandas/tests/series/methods/test_to_frame.py — passes
  • pandas/tests/frame/test_subclass.py — passes
  • pandas/tests/series/test_subclass.py — passes

🤖 Generated with Claude Code

Remove dead GeoDataFrame name-check shim in DataFrame._constructor_from_mgr
since geopandas has overridden _constructor_from_mgr directly since v0.14.3
(Jan 2024).

Remove _constructor_expanddim_from_mgr and inline its logic into
Series.to_frame(), its only call site. Subclasses that need custom
expand-dim behavior can override to_frame directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added the Refactor Internal refactoring of code label Apr 11, 2026
@jorisvandenbossche
Copy link
Copy Markdown
Member

Removing the GeoDataFrame check should be fine now indeed.

Removing _constructor_expanddim_from_mgr (even though used only once) feels a bit inconsistent with the other _constructor... methods, so I would prefer to keep that one just for consistency / clarity.
There will also be projects that are overriding this method (outside of geopandas), although I would generally guess they implement it with similar logic as _constructor_expanddim such that the change wouldn't impact results.

@jbrockmendel
Copy link
Copy Markdown
Member Author

so I would prefer to keep that one just for consistency / clarity

Let's have this argument back in the linked issue. I'll revert this part for this PR.

Revert the inlining of _constructor_expanddim_from_mgr; downstream
subclasses (spatialpandas, timely-beliefs, autogluon, etc.) override
the _from_mgr methods and would break if they were removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jorisvandenbossche jorisvandenbossche changed the title REF: remove GeoDataFrame shim and inline _constructor_expanddim_from_mgr REF: remove GeoDataFrame shim in _constructor_from_mgr Apr 15, 2026
@jorisvandenbossche jorisvandenbossche merged commit 0ce0783 into pandas-dev:main Apr 15, 2026
43 of 45 checks passed
@jorisvandenbossche
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants