Skip to content

Commit 1bb002b

Browse files
Add regression tests
1 parent 03a1316 commit 1bb002b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/test_take.py

+24
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
from pandas._libs import iNaT
88

9+
import pandas as pd
910
import pandas._testing as tm
1011
import pandas.core.algorithms as algos
12+
from pandas.core.array_algos.take import _take_nd_ndarray
1113

1214

1315
@pytest.fixture(params=[True, False])
@@ -332,3 +334,25 @@ def test_take_coerces_list(self):
332334
result = algos.take(arr, [0, 0])
333335
expected = np.array([1, 1])
334336
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

Comments
 (0)