|
6 | 6 |
|
7 | 7 | from pandas._libs import iNaT
|
8 | 8 |
|
| 9 | +import pandas as pd |
9 | 10 | import pandas._testing as tm
|
10 | 11 | import pandas.core.algorithms as algos
|
| 12 | +from pandas.core.array_algos.take import _take_nd_ndarray |
11 | 13 |
|
12 | 14 |
|
13 | 15 | @pytest.fixture(params=[True, False])
|
@@ -332,3 +334,25 @@ def test_take_coerces_list(self):
|
332 | 334 | result = algos.take(arr, [0, 0])
|
333 | 335 | expected = np.array([1, 1])
|
334 | 336 | tm.assert_numpy_array_equal(result, expected)
|
| 337 | + |
| 338 | + |
| 339 | +class TestTakeNumpyNull: |
| 340 | + # GH 46848 |
| 341 | + |
| 342 | + def test_take_2d_axis0_object_object(self): |
| 343 | + arr = np.array([[None]], dtype=object) |
| 344 | + indexer = np.array([0]) |
| 345 | + axis = 1 |
| 346 | + fill_value = None |
| 347 | + allow_fill = False |
| 348 | + |
| 349 | + result = _take_nd_ndarray(arr, indexer, axis, fill_value, allow_fill) |
| 350 | + assert result == [[None]] |
| 351 | + arr2 = np.empty_like(arr) |
| 352 | + result2 = _take_nd_ndarray(arr2, indexer, axis, fill_value, allow_fill) |
| 353 | + assert result2 == [[None]] |
| 354 | + |
| 355 | + def test_take_2d_axis1_object_object(self): |
| 356 | + df = pd.DataFrame(np.empty((1, 1), dtype=object)) |
| 357 | + df[0] = np.empty_like(df[0]) |
| 358 | + df[[0]] |
0 commit comments