Skip to content

Commit 2cd8ee6

Browse files
committed
Add test for apply_raw with xfail
1 parent 07edc87 commit 2cd8ee6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/frame/test_apply.py

+22
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,28 @@ def non_reducing_function(row):
745745
df.apply(func, axis=1)
746746
assert names == list(df.index)
747747

748+
@pytest.mark.xfail(
749+
reason="The 'run once' enhancement for apply_raw not implemented yet."
750+
)
751+
def test_apply_raw_function_runs_once(self):
752+
# https://github.com/pandas-dev/pandas/issues/34506
753+
754+
df = pd.DataFrame({"a": [1, 2, 3]})
755+
values = [] # Save row values function is applied to
756+
757+
def reducing_function(row):
758+
values.extend(row)
759+
760+
def non_reducing_function(row):
761+
values.extend(row)
762+
return row
763+
764+
for func in [reducing_function, non_reducing_function]:
765+
del values[:]
766+
767+
df.apply(func, raw=True, axis=1)
768+
assert values == list(df.a.to_list())
769+
748770
def test_applymap_function_runs_once(self):
749771

750772
df = pd.DataFrame({"a": [1, 2, 3]})

0 commit comments

Comments
 (0)