MCPcopy
hub / github.com/pandas-dev/pandas / test_take_axis_1

Method test_take_axis_1

pandas/tests/test_take.py:227–240  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

225 tm.assert_numpy_array_equal(result, expected)
226
227 def test_take_axis_1(self):
228 arr = np.arange(12).reshape(4, 3)
229 result = algos.take(arr, [0, -1], axis=1)
230 expected = np.array([[0, 2], [3, 5], [6, 8], [9, 11]])
231 tm.assert_numpy_array_equal(result, expected)
232
233 # allow_fill=True
234 result = algos.take(arr, [0, -1], axis=1, allow_fill=True, fill_value=0)
235 expected = np.array([[0, 0], [3, 0], [6, 0], [9, 0]])
236 tm.assert_numpy_array_equal(result, expected)
237
238 # GH#26976 make sure we validate along the correct axis
239 with pytest.raises(IndexError, match="indices are out-of-bounds"):
240 algos.take(arr, [0, 3], axis=1, allow_fill=True, fill_value=0)
241
242 def test_take_non_hashable_fill_value(self):
243 arr = np.array([1, 2, 3])

Callers

nothing calls this directly

Calls 4

reshapeMethod · 0.45
takeMethod · 0.45
arrayMethod · 0.45
raisesMethod · 0.45

Tested by

no test coverage detected