BUG/API: other object type check in Series/DataFrame.equals by jorisvandenbossche · Pull Request #34402 · pandas-dev/pandas (original) (raw)
First, this PR is fixing the "bug" that we shouldn't rely on _constructor
being a class that can be used in isinstance
(see #32638 for the general discussion about this, this is the only place in our code where _constructor
is used like this, AFAIK).
And even if _constructor
would be a class, it wouldn't necessarily be the correct class to check with (or not more correct than type(self)
)
But, so this also brings up the API question: what are the "requirements" we put on the type of other
? Should it be the same type? (as then could also change it to if not type(self) is type(other): ...
)
Or is a subclass sufficient (with isinstance
) ?
The problem with an isinstance checks with subclasses is that then the order matters (eg subdf.equals(df)
would not necessarily give the same answer as df.equals(subdf)
)