@@ -2773,6 +2773,28 @@ def _checkit(axis=0, raw=False):
2773
2773
result = no_cols .apply (lambda x : x .mean (), broadcast = True )
2774
2774
self .assert_ (isinstance (result , DataFrame ))
2775
2775
2776
+ def test_apply_with_args_kwds (self ):
2777
+ def add_some (x , howmuch = 0 ):
2778
+ return x + howmuch
2779
+
2780
+ def agg_and_add (x , howmuch = 0 ):
2781
+ return x .mean () + howmuch
2782
+
2783
+ def subtract_and_divide (x , sub , divide = 1 ):
2784
+ return (x - sub ) / divide
2785
+
2786
+ result = self .frame .apply (add_some , howmuch = 2 )
2787
+ exp = self .frame .apply (lambda x : x + 2 )
2788
+ assert_frame_equal (result , exp )
2789
+
2790
+ result = self .frame .apply (agg_and_add , howmuch = 2 )
2791
+ exp = self .frame .apply (lambda x : x .mean () + 2 )
2792
+ assert_series_equal (result , exp )
2793
+
2794
+ res = self .frame .apply (subtract_and_divide , args = (2 ,), divide = 2 )
2795
+ exp = self .frame .apply (lambda x : (x - 2. ) / 2. )
2796
+ assert_frame_equal (res , exp )
2797
+
2776
2798
def test_applymap (self ):
2777
2799
applied = self .frame .applymap (lambda x : x * 2 )
2778
2800
assert_frame_equal (applied , self .frame * 2 )
0 commit comments