File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff 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 ]})
You can’t perform that action at this time.
0 commit comments