|
10 | 10 | from pandas.errors import PerformanceWarning |
11 | 11 |
|
12 | 12 |
|
13 | | -def test_drop(_index): |
14 | | - dropped = _index.drop([('foo', 'two'), ('qux', 'one')]) |
| 13 | +def test_drop(idx): |
| 14 | + dropped = idx.drop([('foo', 'two'), ('qux', 'one')]) |
15 | 15 |
|
16 | 16 | index = MultiIndex.from_tuples([('foo', 'two'), ('qux', 'one')]) |
17 | | - dropped2 = _index.drop(index) |
| 17 | + dropped2 = idx.drop(index) |
18 | 18 |
|
19 | | - expected = _index[[0, 2, 3, 5]] |
| 19 | + expected = idx[[0, 2, 3, 5]] |
20 | 20 | tm.assert_index_equal(dropped, expected) |
21 | 21 | tm.assert_index_equal(dropped2, expected) |
22 | 22 |
|
23 | | - dropped = _index.drop(['bar']) |
24 | | - expected = _index[[0, 1, 3, 4, 5]] |
| 23 | + dropped = idx.drop(['bar']) |
| 24 | + expected = idx[[0, 1, 3, 4, 5]] |
25 | 25 | tm.assert_index_equal(dropped, expected) |
26 | 26 |
|
27 | | - dropped = _index.drop('foo') |
28 | | - expected = _index[[2, 3, 4, 5]] |
| 27 | + dropped = idx.drop('foo') |
| 28 | + expected = idx[[2, 3, 4, 5]] |
29 | 29 | tm.assert_index_equal(dropped, expected) |
30 | 30 |
|
31 | 31 | index = MultiIndex.from_tuples([('bar', 'two')]) |
32 | | - pytest.raises(KeyError, _index.drop, [('bar', 'two')]) |
33 | | - pytest.raises(KeyError, _index.drop, index) |
34 | | - pytest.raises(KeyError, _index.drop, ['foo', 'two']) |
| 32 | + pytest.raises(KeyError, idx.drop, [('bar', 'two')]) |
| 33 | + pytest.raises(KeyError, idx.drop, index) |
| 34 | + pytest.raises(KeyError, idx.drop, ['foo', 'two']) |
35 | 35 |
|
36 | 36 | # partially correct argument |
37 | 37 | mixed_index = MultiIndex.from_tuples([('qux', 'one'), ('bar', 'two')]) |
38 | | - pytest.raises(KeyError, _index.drop, mixed_index) |
| 38 | + pytest.raises(KeyError, idx.drop, mixed_index) |
39 | 39 |
|
40 | 40 | # error='ignore' |
41 | | - dropped = _index.drop(index, errors='ignore') |
42 | | - expected = _index[[0, 1, 2, 3, 4, 5]] |
| 41 | + dropped = idx.drop(index, errors='ignore') |
| 42 | + expected = idx[[0, 1, 2, 3, 4, 5]] |
43 | 43 | tm.assert_index_equal(dropped, expected) |
44 | 44 |
|
45 | | - dropped = _index.drop(mixed_index, errors='ignore') |
46 | | - expected = _index[[0, 1, 2, 3, 5]] |
| 45 | + dropped = idx.drop(mixed_index, errors='ignore') |
| 46 | + expected = idx[[0, 1, 2, 3, 5]] |
47 | 47 | tm.assert_index_equal(dropped, expected) |
48 | 48 |
|
49 | | - dropped = _index.drop(['foo', 'two'], errors='ignore') |
50 | | - expected = _index[[2, 3, 4, 5]] |
| 49 | + dropped = idx.drop(['foo', 'two'], errors='ignore') |
| 50 | + expected = idx[[2, 3, 4, 5]] |
51 | 51 | tm.assert_index_equal(dropped, expected) |
52 | 52 |
|
53 | 53 | # mixed partial / full drop |
54 | | - dropped = _index.drop(['foo', ('qux', 'one')]) |
55 | | - expected = _index[[2, 3, 5]] |
| 54 | + dropped = idx.drop(['foo', ('qux', 'one')]) |
| 55 | + expected = idx[[2, 3, 5]] |
56 | 56 | tm.assert_index_equal(dropped, expected) |
57 | 57 |
|
58 | 58 | # mixed partial / full drop / error='ignore' |
59 | 59 | mixed_index = ['foo', ('qux', 'one'), 'two'] |
60 | | - pytest.raises(KeyError, _index.drop, mixed_index) |
61 | | - dropped = _index.drop(mixed_index, errors='ignore') |
62 | | - expected = _index[[2, 3, 5]] |
| 60 | + pytest.raises(KeyError, idx.drop, mixed_index) |
| 61 | + dropped = idx.drop(mixed_index, errors='ignore') |
| 62 | + expected = idx[[2, 3, 5]] |
63 | 63 | tm.assert_index_equal(dropped, expected) |
64 | 64 |
|
65 | 65 |
|
66 | | -def test_droplevel_with_names(_index): |
67 | | - index = _index[_index.get_loc('foo')] |
| 66 | +def test_droplevel_with_names(idx): |
| 67 | + index = idx[idx.get_loc('foo')] |
68 | 68 | dropped = index.droplevel(0) |
69 | 69 | assert dropped.name == 'second' |
70 | 70 |
|
|
0 commit comments