Skip to content

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

Closed
wants to merge 11 commits into from

Conversation

gamenerd457
Copy link

-added unittest for issue #43599
-error occurs due to different versions of pandas

@pep8speaks
Copy link

pep8speaks commented Oct 4, 2021

Hello @gamenerd457! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 915:1: E302 expected 2 blank lines, found 0
Line 917:77: W291 trailing whitespace
Line 922:76: W291 trailing whitespace
Line 924:9: E123 closing bracket does not match indentation of opening bracket's line

Line 2864:1: W391 blank line at end of file

Comment last updated at 2021-10-12 07:12:18 UTC

Copy link
Member

@mzeitlin11 mzeitlin11 left a 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)

@mzeitlin11 mzeitlin11 changed the title added test case for issue #43599 TST: changed behavior of df.loc on multiindex Oct 4, 2021
@mzeitlin11 mzeitlin11 added Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Testing pandas testing functions or related to the test suite labels Oct 4, 2021
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.

Please use pre-commit

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

We use pytest

@gamenerd457
Copy link
Author

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)

I have made the changes

@@ -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():
Copy link
Contributor

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

)
df1 = df.loc[np.s_[:, "d", :]]
df2 = df.loc[np.s_[:, "d", :]]
tm.assert_frame_equal(df1, df2)
Copy link
Contributor

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)

index=MultiIndex.from_product([list("abc"), list("de"), list("f")]),
columns=["Val"],
)
df1 = df.loc[np.s_[:, "d", :]]
Copy link
Contributor

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():
Copy link
Contributor

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

Copy link
Contributor

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



Copy link
Contributor

Choose a reason for hiding this comment

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

can you revert these

@jreback
Copy link
Contributor

jreback commented Nov 14, 2021

ca you merge master and update to comments

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Dec 15, 2021
@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Stale Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants