Skip to content

Commit 86429a5

Browse files
committed
Add test for apply_raw with xfail
1 parent 07edc87 commit 86429a5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/frame/test_apply.py

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

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

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

0 commit comments

Comments
 (0)