-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
DeprecateFunctionality to remove in pandasFunctionality to remove in pandasNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionSubclassingSubclassing pandas objectsSubclassing pandas objects
Description
(DataFrame|Series)Subclass._constructor(_sliced|_expanddim)?
does not currently need to return a class. It can return a callable. This means that we cannot write obj._constructor_sliced.some_method
, which has caused bugs/confusion at times. Most recently this surprised a contributor in #51765 and makes the fix there less straightforward.
AFAIK the only/main subclass that relies on this is geopandas, which inspects the arguments to decide which subclass to use. IIUC this could be accomplished with a __new__
method just as easily. cc @jorisvandenbossche
We could even go as far as deprecating _constructor entirely in favor of type(self) and just having _constructor_sliced/_constructor_expanddim.
AdamOrmondroyd
Metadata
Metadata
Assignees
Labels
DeprecateFunctionality to remove in pandasFunctionality to remove in pandasNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionSubclassingSubclassing pandas objectsSubclassing pandas objects