-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: in DataFrame.reset_index() only call maybe_upcast_putmask with ndarrays #36876
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
Conversation
@@ -650,6 +650,32 @@ def test_loc_slice(self): | |||
expected = self.df.iloc[[2, 3, 4]] | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_reindexing_with_missing_values(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you parameterize both of the examples from the OP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -650,6 +650,32 @@ def test_loc_slice(self): | |||
expected = self.df.iloc[[2, 3, 4]] | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_reindexing_with_missing_values(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to pandas/tests/frame/test_alter_axes.py
you can make a new class there if you'd like and put this there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
) | ||
|
||
tm.assert_frame_equal(res, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also round-trip again, e.g. .set_index(['level_0', 'level_1']).reset_index()
and compare with expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -650,6 +650,32 @@ def test_loc_slice(self): | |||
expected = self.df.iloc[[2, 3, 4]] | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_reindexing_with_missing_values(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -650,6 +650,32 @@ def test_loc_slice(self): | |||
expected = self.df.iloc[[2, 3, 4]] | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_reindexing_with_missing_values(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
) | ||
|
||
tm.assert_frame_equal(res, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -171,21 +173,6 @@ def test_assign_columns(self, float_frame): | |||
tm.assert_series_equal(float_frame["C"], df["baz"], check_names=False) | |||
tm.assert_series_equal(float_frame["hi"], df["foo2"], check_names=False) | |||
|
|||
def test_set_index_preserve_categorical_dtype(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to sit with the only other categorical test (the one I'm adding) in TestCategoricalIndex
class
pandas/core/frame.py
Outdated
if mask.any(): | ||
if isinstance(values, np.ndarray): | ||
values, _ = maybe_upcast_putmask(values, mask, np.nan) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback added this since you last looked - we handle nan
in maybe_upcast_mask
if values is an ndarray
else fill with np.nan
can you merge master and ping on green-ish |
@jreback Green-ish (the failures are 6 tests from |
@jreback all green now |
thanks @arw2019 |
Thanks @jreback for reviewing! |
…darrays (pandas-dev#36876) * BUG: add check so maybe_upcast_putmask is only called with ndarray * TST: add tests * DOC: add whatsnew * feedback: test roundtrip * feedback: parametrize on both examples from OP * move test to frame/test_alter_axes.py * fill mask in index with nan when not calling maybe_upcast_putmask * restore the fix
…darrays (pandas-dev#36876) * BUG: add check so maybe_upcast_putmask is only called with ndarray * TST: add tests * DOC: add whatsnew * feedback: test roundtrip * feedback: parametrize on both examples from OP * move test to frame/test_alter_axes.py * fill mask in index with nan when not calling maybe_upcast_putmask * restore the fix
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff