|
8 | 8 | import pytest
|
9 | 9 |
|
10 | 10 | from pandas._libs import iNaT
|
11 |
| -from pandas.errors import InvalidIndexError |
| 11 | +from pandas.errors import ( |
| 12 | + InvalidIndexError, |
| 13 | + SettingWithCopyError, |
| 14 | +) |
12 | 15 | import pandas.util._test_decorators as td
|
13 | 16 |
|
14 | 17 | from pandas.core.dtypes.common import is_integer
|
|
27 | 30 | notna,
|
28 | 31 | )
|
29 | 32 | import pandas._testing as tm
|
30 |
| -import pandas.core.common as com |
31 | 33 |
|
32 | 34 | # We pass through a TypeError raised by numpy
|
33 | 35 | _slice_msg = "slice indices must be integers or None or have an __index__ method"
|
@@ -303,7 +305,7 @@ def test_setitem(self, float_frame):
|
303 | 305 | smaller = float_frame[:2]
|
304 | 306 |
|
305 | 307 | msg = r"\nA value is trying to be set on a copy of a slice from a DataFrame"
|
306 |
| - with pytest.raises(com.SettingWithCopyError, match=msg): |
| 308 | + with pytest.raises(SettingWithCopyError, match=msg): |
307 | 309 | smaller["col10"] = ["1", "2"]
|
308 | 310 |
|
309 | 311 | assert smaller["col10"].dtype == np.object_
|
@@ -546,7 +548,7 @@ def test_fancy_getitem_slice_mixed(self, float_frame, float_string_frame):
|
546 | 548 | assert np.shares_memory(sliced["C"]._values, float_frame["C"]._values)
|
547 | 549 |
|
548 | 550 | msg = r"\nA value is trying to be set on a copy of a slice from a DataFrame"
|
549 |
| - with pytest.raises(com.SettingWithCopyError, match=msg): |
| 551 | + with pytest.raises(SettingWithCopyError, match=msg): |
550 | 552 | sliced.loc[:, "C"] = 4.0
|
551 | 553 |
|
552 | 554 | assert (float_frame["C"] == 4).all()
|
@@ -1003,7 +1005,7 @@ def test_iloc_row_slice_view(self, using_array_manager):
|
1003 | 1005 | assert np.shares_memory(df[2], subset[2])
|
1004 | 1006 |
|
1005 | 1007 | msg = r"\nA value is trying to be set on a copy of a slice from a DataFrame"
|
1006 |
| - with pytest.raises(com.SettingWithCopyError, match=msg): |
| 1008 | + with pytest.raises(SettingWithCopyError, match=msg): |
1007 | 1009 | subset.loc[:, 2] = 0.0
|
1008 | 1010 |
|
1009 | 1011 | exp_col = original[2].copy()
|
@@ -1046,7 +1048,7 @@ def test_iloc_col_slice_view(self, using_array_manager):
|
1046 | 1048 |
|
1047 | 1049 | # and that we are setting a copy
|
1048 | 1050 | msg = r"\nA value is trying to be set on a copy of a slice from a DataFrame"
|
1049 |
| - with pytest.raises(com.SettingWithCopyError, match=msg): |
| 1051 | + with pytest.raises(SettingWithCopyError, match=msg): |
1050 | 1052 | subset.loc[:, 8] = 0.0
|
1051 | 1053 |
|
1052 | 1054 | assert (df[8] == 0).all()
|
|
0 commit comments