Open
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.