-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: changed behavior of df.loc on multiindex #43879
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
Hello @gamenerd457! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-10-12 07:12:18 UTC |
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.
Thanks for the pr @gamenerd457. Please look at the contributing guide (https://pandas.pydata.org/docs/development/index.html#development), especially the portions about testing (we don't use unittest
) and style (this is currently failing checks)
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.
Please use pre-commit
pandas/tests/indexing/test_loc.py
Outdated
@@ -38,6 +38,7 @@ | |||
from pandas.api.types import is_scalar | |||
from pandas.core.api import Float64Index | |||
from pandas.tests.indexing.common import Base | |||
import unittest |
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.
We use pytest
I have made the changes |
pandas/tests/indexing/test_loc.py
Outdated
@@ -2857,3 +2858,14 @@ def test_loc_set_multiple_items_in_multiple_new_columns(self): | |||
) | |||
|
|||
tm.assert_frame_equal(df, expected) | |||
|
|||
|
|||
def test_loc_multiindex(): |
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 this to pandas/tests/indexing/multiindex/test_loc.py
add the issue number as a comment
pandas/tests/indexing/test_loc.py
Outdated
) | ||
df1 = df.loc[np.s_[:, "d", :]] | ||
df2 = df.loc[np.s_[:, "d", :]] | ||
tm.assert_frame_equal(df1, df2) |
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.
use
tm.assert_frame_equal(result, expected)
pandas/tests/indexing/test_loc.py
Outdated
index=MultiIndex.from_product([list("abc"), list("de"), list("f")]), | ||
columns=["Val"], | ||
) | ||
df1 = df.loc[np.s_[:, "d", :]] |
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.
umm these look the same. the test should hard code the expected construction.
@@ -912,3 +912,14 @@ def test_loc_keyerror_rightmost_key_missing(): | |||
df = df.set_index(["A", "B"]) | |||
with pytest.raises(KeyError, match="^1$"): | |||
df.loc[(100, 1)] | |||
def test_loc_multiindex(): |
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.
need a blank line between functions or this will fail linting
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 be more specific on the naem
and add the issue number as a commetn
@@ -40,6 +40,7 @@ | |||
from pandas.tests.indexing.common import Base | |||
|
|||
|
|||
|
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 revert these
ca you merge master and update to comments |
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
Thanks for the PR but appears to have gone stale. If interested in continuing please merge the main branch, address the review, and we can reopen. |
-added unittest for issue #43599
-error occurs due to different versions of pandas