|
6 | 6 |
|
7 | 7 | from pandas._libs import iNaT
|
8 | 8 |
|
9 |
| -from pandas.core.dtypes.common import is_float_dtype, is_integer |
| 9 | +from pandas.core.dtypes.common import is_integer |
10 | 10 |
|
11 | 11 | import pandas as pd
|
12 | 12 | from pandas import (
|
@@ -1327,120 +1327,6 @@ def test_getitem_list_duplicates(self):
|
1327 | 1327 | expected = df.iloc[:, 2:]
|
1328 | 1328 | tm.assert_frame_equal(result, expected)
|
1329 | 1329 |
|
1330 |
| - def test_get_value(self, float_frame): |
1331 |
| - for idx in float_frame.index: |
1332 |
| - for col in float_frame.columns: |
1333 |
| - result = float_frame._get_value(idx, col) |
1334 |
| - expected = float_frame[col][idx] |
1335 |
| - assert result == expected |
1336 |
| - |
1337 |
| - def test_lookup_float(self, float_frame): |
1338 |
| - df = float_frame |
1339 |
| - rows = list(df.index) * len(df.columns) |
1340 |
| - cols = list(df.columns) * len(df.index) |
1341 |
| - with tm.assert_produces_warning(FutureWarning): |
1342 |
| - result = df.lookup(rows, cols) |
1343 |
| - |
1344 |
| - expected = np.array([df.loc[r, c] for r, c in zip(rows, cols)]) |
1345 |
| - tm.assert_numpy_array_equal(result, expected) |
1346 |
| - |
1347 |
| - def test_lookup_mixed(self, float_string_frame): |
1348 |
| - df = float_string_frame |
1349 |
| - rows = list(df.index) * len(df.columns) |
1350 |
| - cols = list(df.columns) * len(df.index) |
1351 |
| - with tm.assert_produces_warning(FutureWarning): |
1352 |
| - result = df.lookup(rows, cols) |
1353 |
| - |
1354 |
| - expected = np.array( |
1355 |
| - [df.loc[r, c] for r, c in zip(rows, cols)], dtype=np.object_ |
1356 |
| - ) |
1357 |
| - tm.assert_almost_equal(result, expected) |
1358 |
| - |
1359 |
| - def test_lookup_bool(self): |
1360 |
| - df = DataFrame( |
1361 |
| - { |
1362 |
| - "label": ["a", "b", "a", "c"], |
1363 |
| - "mask_a": [True, True, False, True], |
1364 |
| - "mask_b": [True, False, False, False], |
1365 |
| - "mask_c": [False, True, False, True], |
1366 |
| - } |
1367 |
| - ) |
1368 |
| - with tm.assert_produces_warning(FutureWarning): |
1369 |
| - df["mask"] = df.lookup(df.index, "mask_" + df["label"]) |
1370 |
| - |
1371 |
| - exp_mask = np.array( |
1372 |
| - [df.loc[r, c] for r, c in zip(df.index, "mask_" + df["label"])] |
1373 |
| - ) |
1374 |
| - |
1375 |
| - tm.assert_series_equal(df["mask"], Series(exp_mask, name="mask")) |
1376 |
| - assert df["mask"].dtype == np.bool_ |
1377 |
| - |
1378 |
| - def test_lookup_raises(self, float_frame): |
1379 |
| - with pytest.raises(KeyError, match="'One or more row labels was not found'"): |
1380 |
| - with tm.assert_produces_warning(FutureWarning): |
1381 |
| - float_frame.lookup(["xyz"], ["A"]) |
1382 |
| - |
1383 |
| - with pytest.raises(KeyError, match="'One or more column labels was not found'"): |
1384 |
| - with tm.assert_produces_warning(FutureWarning): |
1385 |
| - float_frame.lookup([float_frame.index[0]], ["xyz"]) |
1386 |
| - |
1387 |
| - with pytest.raises(ValueError, match="same size"): |
1388 |
| - with tm.assert_produces_warning(FutureWarning): |
1389 |
| - float_frame.lookup(["a", "b", "c"], ["a"]) |
1390 |
| - |
1391 |
| - def test_lookup_requires_unique_axes(self): |
1392 |
| - # GH#33041 raise with a helpful error message |
1393 |
| - df = DataFrame(np.random.randn(6).reshape(3, 2), columns=["A", "A"]) |
1394 |
| - |
1395 |
| - rows = [0, 1] |
1396 |
| - cols = ["A", "A"] |
1397 |
| - |
1398 |
| - # homogeneous-dtype case |
1399 |
| - with pytest.raises(ValueError, match="requires unique index and columns"): |
1400 |
| - with tm.assert_produces_warning(FutureWarning): |
1401 |
| - df.lookup(rows, cols) |
1402 |
| - with pytest.raises(ValueError, match="requires unique index and columns"): |
1403 |
| - with tm.assert_produces_warning(FutureWarning): |
1404 |
| - df.T.lookup(cols, rows) |
1405 |
| - |
1406 |
| - # heterogeneous dtype |
1407 |
| - df["B"] = 0 |
1408 |
| - with pytest.raises(ValueError, match="requires unique index and columns"): |
1409 |
| - with tm.assert_produces_warning(FutureWarning): |
1410 |
| - df.lookup(rows, cols) |
1411 |
| - |
1412 |
| - def test_set_value(self, float_frame): |
1413 |
| - for idx in float_frame.index: |
1414 |
| - for col in float_frame.columns: |
1415 |
| - float_frame._set_value(idx, col, 1) |
1416 |
| - assert float_frame[col][idx] == 1 |
1417 |
| - |
1418 |
| - def test_set_value_resize(self, float_frame): |
1419 |
| - |
1420 |
| - res = float_frame._set_value("foobar", "B", 0) |
1421 |
| - assert res is None |
1422 |
| - assert float_frame.index[-1] == "foobar" |
1423 |
| - assert float_frame._get_value("foobar", "B") == 0 |
1424 |
| - |
1425 |
| - float_frame.loc["foobar", "qux"] = 0 |
1426 |
| - assert float_frame._get_value("foobar", "qux") == 0 |
1427 |
| - |
1428 |
| - res = float_frame.copy() |
1429 |
| - res._set_value("foobar", "baz", "sam") |
1430 |
| - assert res["baz"].dtype == np.object_ |
1431 |
| - |
1432 |
| - res = float_frame.copy() |
1433 |
| - res._set_value("foobar", "baz", True) |
1434 |
| - assert res["baz"].dtype == np.object_ |
1435 |
| - |
1436 |
| - res = float_frame.copy() |
1437 |
| - res._set_value("foobar", "baz", 5) |
1438 |
| - assert is_float_dtype(res["baz"]) |
1439 |
| - assert isna(res["baz"].drop(["foobar"])).all() |
1440 |
| - msg = "could not convert string to float: 'sam'" |
1441 |
| - with pytest.raises(ValueError, match=msg): |
1442 |
| - res._set_value("foobar", "baz", "sam") |
1443 |
| - |
1444 | 1330 | def test_reindex_with_multi_index(self):
|
1445 | 1331 | # https://github.com/pandas-dev/pandas/issues/29896
|
1446 | 1332 | # tests for reindexing a multi-indexed DataFrame with a new MultiIndex
|
@@ -1542,13 +1428,6 @@ def test_set_value_with_index_dtype_change(self):
|
1542 | 1428 | assert list(df.index) == list(df_orig.index) + ["C"]
|
1543 | 1429 | assert list(df.columns) == list(df_orig.columns) + ["D"]
|
1544 | 1430 |
|
1545 |
| - def test_get_set_value_no_partial_indexing(self): |
1546 |
| - # partial w/ MultiIndex raise exception |
1547 |
| - index = MultiIndex.from_tuples([(0, 1), (0, 2), (1, 1), (1, 2)]) |
1548 |
| - df = DataFrame(index=index, columns=range(4)) |
1549 |
| - with pytest.raises(KeyError, match=r"^0$"): |
1550 |
| - df._get_value(0, 1) |
1551 |
| - |
1552 | 1431 | # TODO: rename? remove?
|
1553 | 1432 | def test_single_element_ix_dont_upcast(self, float_frame):
|
1554 | 1433 | float_frame["E"] = 1
|
@@ -2251,12 +2130,3 @@ def test_object_casting_indexing_wraps_datetimelike():
|
2251 | 2130 | assert blk.dtype == "m8[ns]" # we got the right block
|
2252 | 2131 | val = blk.iget((0, 0))
|
2253 | 2132 | assert isinstance(val, pd.Timedelta)
|
2254 |
| - |
2255 |
| - |
2256 |
| -def test_lookup_deprecated(): |
2257 |
| - # GH18262 |
2258 |
| - df = DataFrame( |
2259 |
| - {"col": ["A", "A", "B", "B"], "A": [80, 23, np.nan, 22], "B": [80, 55, 76, 67]} |
2260 |
| - ) |
2261 |
| - with tm.assert_produces_warning(FutureWarning): |
2262 |
| - df.lookup(df.index, df["col"]) |
0 commit comments