Skip to content

Commit de593d3

Browse files
committed
BUG: Fix DataFrame.apply(..., raw=True) not calling with raw array
1 parent d33b002 commit de593d3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pandas/core/apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def get_result(self):
179179
return self.apply_empty_result()
180180

181181
# raw
182-
elif self.raw and not self.obj._is_mixed_type:
182+
elif self.raw:
183183
return self.apply_raw()
184184

185185
return self.apply_standard()

pandas/tests/frame/test_apply.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_apply_broadcast_error(self, int_frame_const_col):
235235
with pytest.raises(ValueError):
236236
df.apply(lambda x: Series([1, 2]), axis=1, result_type="broadcast")
237237

238-
def test_apply_raw(self, float_frame):
238+
def test_apply_raw(self, float_frame, mixed_type_frame):
239239
result0 = float_frame.apply(np.mean, raw=True)
240240
result1 = float_frame.apply(np.mean, axis=1, raw=True)
241241

@@ -250,6 +250,13 @@ def test_apply_raw(self, float_frame):
250250
expected = float_frame * 2
251251
tm.assert_frame_equal(result, expected)
252252

253+
# Mixed dtype
254+
def _assert_raw(x):
255+
assert isinstance(x, np.ndarray)
256+
257+
mixed_type_frame.apply(_assert_raw, raw=True)
258+
mixed_type_frame.apply(_assert_raw, axis=1, raw=True)
259+
253260
def test_apply_axis1(self, float_frame):
254261
d = float_frame.index[0]
255262
tapplied = float_frame.apply(np.mean, axis=1)

0 commit comments

Comments
 (0)