-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: assignment with enlargement gives object dtype with ExtensionArrays #32346
Comments
This works now. Returns:
|
take |
@phofl I found the same issue still occurring for other dtypes apart from Int64.
My observations for some of the inconsistent dtype conversions are as follows:
Also, these inconsistent conversion only occur for assignments to indexes that do not exist in the original array. |
This seems odd, but not sure if this is deliberate. This happens in pandas/pandas/core/indexing.py Line 1890 in 9415d10
Maybe we should try to preserve the dtype? @jbrockmendel thoughts? |
Agreed. |
I looked into this. This seems deliberate for now.
This results in object for Float. The int case is the same as for non nullable dtypes. int32 is also changed to int64 |
id try to avoid object wherever possible. maybe instead of requiring all-FloatingDtype could require all losslessly-castable, so would include numpy floating dtypes and some numpy integer dtypes |
but not for the pd.NA case
xref #47214 (comment) |
That last one is actually a regression (I ran into this a few days ago and was planning to open a new issue). This was working in 1.3 (and already in 1.1 as well):
while on 1.4 / main, this results in object dtype |
Thanks @jorisvandenbossche will open a dedicated issue for the regression. |
opened #47284 |
Works now |
There was a specific PR for this that added tests (#47342), so just closing. |
Actually, we still have the issue for EAs in general (for external EAs, how they can preserve the dtype / recognize scalars), as I mentioned in the top post this also happens for our test DecimalArray. And this still doesn't work:
So we can keep this open for ExtensionArrays in general. |
From #32271, when setting with enlargment, the dtype gets converted into object dtype (while for normal integer or boolean dtype this is not the case):
It also happens with eg DecimalArray from our tests, so suppose it is a general issue with ExtensionArrays.
The text was updated successfully, but these errors were encountered: