-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: MultiIndex.putmask losing ea dtype #49847
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,34 @@ def test_putmask_multiindex_other(self): | |
expected = MultiIndex.from_tuples([right[0], right[1], left[2]]) | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_putmask_keep_dtype(self, any_numeric_ea_dtype): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the two test cases also covering for the all-nan case in #49830 (comment) or do you think it's not necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's about losing the dtype, so yes this covers the all nan case. But this does not fix the issue yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable might be a misnomer then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It covers the case in a sense that the current tests represent the all nan case as well, I’ll add a specific test when actually fixing the issue anyway |
||
# GH#49830 | ||
midx = MultiIndex.from_arrays( | ||
[pd.Series([1, 2, 3], dtype=any_numeric_ea_dtype), [10, 11, 12]] | ||
) | ||
midx2 = MultiIndex.from_arrays( | ||
[pd.Series([5, 6, 7], dtype=any_numeric_ea_dtype), [-1, -2, -3]] | ||
) | ||
result = midx.putmask([True, False, False], midx2) | ||
expected = MultiIndex.from_arrays( | ||
[pd.Series([5, 2, 3], dtype=any_numeric_ea_dtype), [-1, 11, 12]] | ||
) | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_putmask_keep_dtype_shorter_value(self, any_numeric_ea_dtype): | ||
# GH#49830 | ||
midx = MultiIndex.from_arrays( | ||
[pd.Series([1, 2, 3], dtype=any_numeric_ea_dtype), [10, 11, 12]] | ||
) | ||
midx2 = MultiIndex.from_arrays( | ||
[pd.Series([5], dtype=any_numeric_ea_dtype), [-1]] | ||
) | ||
result = midx.putmask([True, False, False], midx2) | ||
expected = MultiIndex.from_arrays( | ||
[pd.Series([5, 2, 3], dtype=any_numeric_ea_dtype), [-1, 11, 12]] | ||
) | ||
tm.assert_index_equal(result, expected) | ||
|
||
|
||
class TestGetIndexer: | ||
def test_get_indexer(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.