Skip to content

Commit a4bfe80

Browse files
committed
assert raw also for single dtype; assert ndim == 1
1 parent de593d3 commit a4bfe80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/tests/frame/test_apply.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ def test_apply_broadcast_error(self, int_frame_const_col):
236236
df.apply(lambda x: Series([1, 2]), axis=1, result_type="broadcast")
237237

238238
def test_apply_raw(self, float_frame, mixed_type_frame):
239+
240+
def _assert_raw(x):
241+
assert isinstance(x, np.ndarray)
242+
assert x.ndim == 1
243+
244+
float_frame.apply(_assert_raw, raw=True)
245+
float_frame.apply(_assert_raw, axis=1, raw=True)
246+
239247
result0 = float_frame.apply(np.mean, raw=True)
240248
result1 = float_frame.apply(np.mean, axis=1, raw=True)
241249

@@ -250,10 +258,7 @@ def test_apply_raw(self, float_frame, mixed_type_frame):
250258
expected = float_frame * 2
251259
tm.assert_frame_equal(result, expected)
252260

253-
# Mixed dtype
254-
def _assert_raw(x):
255-
assert isinstance(x, np.ndarray)
256-
261+
# Mixed dtype (GH-32423)
257262
mixed_type_frame.apply(_assert_raw, raw=True)
258263
mixed_type_frame.apply(_assert_raw, axis=1, raw=True)
259264

0 commit comments

Comments
 (0)