File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -745,6 +745,27 @@ def non_reducing_function(row):
745
745
df .apply (func , axis = 1 )
746
746
assert names == list (df .index )
747
747
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
+
748
769
def test_applymap_function_runs_once (self ):
749
770
750
771
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]})
You can’t perform that action at this time.
0 commit comments