Skip to content

add a test for loc method; check if a warning raise when replacing a … #36486

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 11 commits into from
Sep 22, 2020
Merged
8 changes: 5 additions & 3 deletions pandas/tests/indexing/test_chaining_and_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,14 @@ def test_setting_with_copy_bug(self):
# this should not raise
df2["y"] = ["g", "h", "i"]

def test_detect_chained_assignment_warnings(self):
def test_detect_chained_assignment_warnings_errors(self):
df = DataFrame({"A": ["aaa", "bbb", "ccc"], "B": [1, 2, 3]})
with option_context("chained_assignment", "warn"):
df = DataFrame({"A": ["aaa", "bbb", "ccc"], "B": [1, 2, 3]})

with tm.assert_produces_warning(com.SettingWithCopyWarning):
df.loc[0]["A"] = 111
with option_context("chained_assignment", "raise"):
with pytest.raises(com.SettingWithCopyError):
df.loc[0]["A"] = 111

def test_detect_chained_assignment_warnings_filter_and_dupe_cols(self):
# xref gh-13017.
Expand Down