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
10 changes: 10 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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



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

class TestLoc(Base):
Expand Down Expand Up @@ -2857,3 +2858,12 @@ def test_loc_set_multiple_items_in_multiple_new_columns(self):
)

tm.assert_frame_equal(df, expected)
class TestLoc3(unittest.TestCase):
#test case for issue #43599
def test_loc_multiindex(self):
df = DataFrame(index=MultiIndex.from_product([list('abc'), list('de'), list('f')]), columns=['Val'])
df1=df.loc[np.s_[:,'d',:]]
df2=DataFrame(index=MultiIndex.from_product([list('abc'), list('d'), list('f')]), columns=['Val'])
tm.assert_frame_equal(df1,df2)