|
12 | 12 | Series,
|
13 | 13 | Timestamp,
|
14 | 14 | date_range,
|
| 15 | + option_context, |
15 | 16 | period_range,
|
16 | 17 | )
|
17 | 18 | import pandas._testing as tm
|
@@ -1684,7 +1685,7 @@ def test_get(using_copy_on_write, warn_copy_on_write, key):
|
1684 | 1685 | warn = FutureWarning if isinstance(key, str) else None
|
1685 | 1686 | else:
|
1686 | 1687 | warn = SettingWithCopyWarning if isinstance(key, list) else None
|
1687 |
| - with pd.option_context("chained_assignment", "warn"): |
| 1688 | + with option_context("chained_assignment", "warn"): |
1688 | 1689 | with tm.assert_produces_warning(warn):
|
1689 | 1690 | result.iloc[0] = 0
|
1690 | 1691 |
|
@@ -1721,7 +1722,7 @@ def test_xs(
|
1721 | 1722 | with tm.assert_cow_warning(single_block or axis == 1):
|
1722 | 1723 | result.iloc[0] = 0
|
1723 | 1724 | else:
|
1724 |
| - with pd.option_context("chained_assignment", "warn"): |
| 1725 | + with option_context("chained_assignment", "warn"): |
1725 | 1726 | with tm.assert_produces_warning(SettingWithCopyWarning):
|
1726 | 1727 | result.iloc[0] = 0
|
1727 | 1728 |
|
@@ -1756,7 +1757,7 @@ def test_xs_multiindex(
|
1756 | 1757 | warn = SettingWithCopyWarning
|
1757 | 1758 | else:
|
1758 | 1759 | warn = None
|
1759 |
| - with pd.option_context("chained_assignment", "warn"): |
| 1760 | + with option_context("chained_assignment", "warn"): |
1760 | 1761 | with tm.assert_produces_warning(warn):
|
1761 | 1762 | result.iloc[0, 0] = 0
|
1762 | 1763 |
|
@@ -1813,6 +1814,17 @@ def test_update_chained_assignment(using_copy_on_write):
|
1813 | 1814 | with tm.raises_chained_assignment_error():
|
1814 | 1815 | df[["a"]].update(ser2.to_frame())
|
1815 | 1816 | tm.assert_frame_equal(df, df_orig)
|
| 1817 | + else: |
| 1818 | + with tm.assert_produces_warning(FutureWarning, match="inplace method"): |
| 1819 | + df["a"].update(ser2) |
| 1820 | + |
| 1821 | + with tm.assert_produces_warning(FutureWarning, match="inplace method"): |
| 1822 | + with option_context("mode.chained_assignment", None): |
| 1823 | + df[["a"]].update(ser2.to_frame()) |
| 1824 | + |
| 1825 | + with tm.assert_produces_warning(FutureWarning, match="inplace method"): |
| 1826 | + with option_context("mode.chained_assignment", None): |
| 1827 | + df[df["a"] > 1].update(ser2.to_frame()) |
1816 | 1828 |
|
1817 | 1829 |
|
1818 | 1830 | def test_inplace_arithmetic_series(using_copy_on_write):
|
|
0 commit comments