GH1396 Add concat compatibility for subclasses of DataFrame#1713
GH1396 Add concat compatibility for subclasses of DataFrame#1713loicdiridollou wants to merge 3 commits intopandas-dev:mainfrom
Conversation
There was a problem hiding this comment.
Would it make sense to merge these two overloads?
There was a problem hiding this comment.
Not super clear to me how we could combine both since everything that is NDFrame should go to DataFrame and anything DataFrame compatible should maintain the type. Did you have an idea about how to implement that?
There was a problem hiding this comment.
It seems to me that DataFrame is the only subclass of NDFrame. What if you use NDFrameT (already in _typing) instead of DataFrameT0?
There was a problem hiding this comment.
Series is also a subclass of NDFrame, the issue arises when you have a list of [None, Series, DataFrame] it will give the return type as DataFrame | Series but we want DataFrame (the NDFrameT matches to the type of the union and not the "bigger" type). Not sure if that was clear
There was a problem hiding this comment.
https://github.com/pandas-dev/pandas-stubs/actions/runs/23871184309/job/69603313845?pr=1713
See that run with all the lints
There was a problem hiding this comment.
Oops, my bad, somehow forgot Series is also a subclass of NDFrame.
If mixing Series and DataFrame gives DataFrame, what if people mix Series and subclasses of DataFrame and complain that pandas-stubs doesn't serve them right?
There was a problem hiding this comment.
Not sure there is a way to do so, I tried with Iterable[DataFrameT0 | NDFrame | None] and it is raising a lot of issues with Unknown. I would say in general that this is not what is intended like a Geopandas and a Series should not be allowed.
56faa72 to
a2743db
Compare
pd.concatwithGeoDataFrames #1396assert_type()to assert the type of any return value)AGENTS.md.