-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: ExtensionDtype._dtype_with_na/_maybe_promote #45349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is already a |
The question isn't "can this store an NA", it's "given that it can't, what's the closest dtype that can?" |
Just discovered there are a couple places in core.indexing where we call maybe_promote (which is annotated as only taking numpy dtypes) with potentially-EA dtypes. Inside maybe_promote we have special handling for CategoricalDtype (which is reached in the tests). And outside maybe_promote in the indexing code with have |
Or alternatively: longer term, every EA can hold NAs, or otherwise raise an error if we try to put NAs in it (this also relates to the proposal to preserve dtypes in setitem-like operations). (I know this doesn't solve the specific issue for Interval[int], but if that's the currently the only one that gives a wrong result in |
ATM
dtypes.cast.ensure_dtype_can_hold_na
is incorrect for EA dtypes that cannot hold NA values (theIntervalDtype[int]
example is the only one that comes to mind).We have special-casing for IntervalDtype in
Index._find_common_type_compat
which is why the Index methods above behave well. Short-term, we can move that special-casing intoensure_dtype_can_hold_na
. Longer-term, we need a way for EADtype subclasses to specify this behavior.This could be seen as a special case of xref #24246
cc @jorisvandenbossche @TomAugspurger
The text was updated successfully, but these errors were encountered: