Skip to content

TST: setting value at MultiIndex slice using .loc #37513

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

Merged
merged 2 commits into from
Oct 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,24 @@ def test_loc_getitem_access_none_value_in_multiindex(self):
result = ser.loc[("Level1", "Level2_a")]
assert result == 1

def test_loc_setitem_multiindex_slice(self):
# GH 34870

index = pd.MultiIndex.from_tuples(
zip(
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
["one", "two", "one", "two", "one", "two", "one", "two"],
),
names=["first", "second"],
)

result = Series([1, 1, 1, 1, 1, 1, 1, 1], index=index)
result.loc[("baz", "one"):("foo", "two")] = 100

expected = Series([1, 1, 100, 100, 100, 100, 1, 1], index=index)

tm.assert_series_equal(result, expected)


def test_series_loc_getitem_label_list_missing_values():
# gh-11428
Expand Down