Skip to content

BUG FIX: incorrect type when casting to nullable type in multiindex dataframe #47419

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

Closed
wants to merge 8 commits into from

Conversation

weikhor
Copy link
Contributor

@weikhor weikhor commented Jun 19, 2022

@weikhor weikhor closed this Jun 19, 2022
@weikhor weikhor reopened this Aug 1, 2022
@mroeschke mroeschke added MultiIndex NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Aug 1, 2022
@@ -227,3 +227,17 @@ def test_multiindex_repeated_keys(self):
],
Series([1, 1, 2, 2], MultiIndex.from_arrays([["a", "a", "b", "b"]])),
)

@pytest.mark.parametrize("data_type", ["int64", "int32", "float64", "float32"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use any_signed_int_ea_dtype

@@ -11917,6 +11917,11 @@ def _reindex_for_setitem(value: DataFrame | Series, index: Index) -> ArrayLike:
# reindex if necessary

if value.index.equals(index) or not len(index):
if isinstance(value, DataFrame):
dtype_list = value.dtypes.unique()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use find_common_type

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not see this yesterday when opening my pr. #48094

We have to set column wise here, otherwise we will cast dtypes as soon as we have multiple dtypes in our value to set, for example #20476.

We are doing the same if the indexer is a list of keys

@weikhor
Copy link
Contributor Author

weikhor commented Aug 16, 2022

Did not see this yesterday when opening my pr. #48094

We have to set column wise here, otherwise we will cast dtypes as soon as we have multiple dtypes in our value to set, for example #20476.

We are doing the same if the indexer is a list of keys

Ok I will close my PR. Your PR is much better. Will look at your solution.

@weikhor weikhor closed this Aug 16, 2022
@weikhor weikhor deleted the 46896_multiindex_dataframe branch August 16, 2022 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: incorrect type when casting to nullable type in multiindex dataframe
3 participants