API: inconsistency in casting back to its EA dtype (try_cast_to_ea) #31108
Labels
API - Consistency
Internal Consistency of API/Behavior
Bug
ExtensionArray
Extending pandas with custom dtypes or arrays.
With the current logic we have in
try_cast_to_ea
:pandas/pandas/core/arrays/base.py
Lines 49 to 54 in a72eef5
it's easy to get inconsistencies, and it depends critically on what
_from_sequence
accepts as valid scalar.For example, we now have this
However, if the IntegerArray constructor gets changed slightly to be more willing to accept all kinds of boolean like values (see #31104 for a current inconsistency on this aspect, and this is what happens in #30282), you can get:
So how "forgiving" the EA constructor is, will determine the output type.
Here the example is with
combine
, but thetry_cast_to_ea
function is also used in a part ofgroupby
.The text was updated successfully, but these errors were encountered: