ENH: general concat with ExtensionArrays through find_common_type by jorisvandenbossche · Pull Request #33607 · pandas-dev/pandas (original) (raw)
Are we implicitly assuming that
self.dtype
is a member ofdtypes
?
Right now, this is the case yes. What do you mean with making that explicit? (just better documenting it?)
Should
_get_common_type
be a classmethod?
It could be, but personally I don't really see to not make it an instance method. Yes, self
will always be in the list of dtypes
(see question above), but I can assume that for the implementation it can be useful to know self (instead of needing to infer it from the list of dtypes). Not that this should impact the result, I only think it can be handy in the implementation (but this is rather hypothetical feeling at the moment).
The main thing is: we always call this from the instance, so I don't see much value in making it a class method instead of instance method.
In the case (mentioned in a comment on the base class) where
dtypes
is a singleton, can we require that the return value be that dtype?
This is the only sensible return value in such a case (an EA doing anything different will behave very strange). But what do you mean with "require"? Better document it? Or we could have a base extension test that asserts it?
But see also my question above (#33607 (comment)): in principle we don't even need to call this _get_common_type
method if there is only one dtype in the list. In the concat code / find_common_type
code, we can simply use this dtype and shortcut calling _get_common_type
.
Can we nail down the common_type vs common_dtype semantics before pushing this through? I feel like that has been a major cause of trouble with the existing concat code.
Can you explain this a bit more? I am not aware of any troubles regarding that.