@@ -95,9 +95,9 @@ def test_apply_empty(self, float_frame, empty_frame):
95
95
tm .assert_series_equal (result , expected )
96
96
97
97
# 2476
98
- xp = DataFrame (index = ['a' ])
99
- rs = xp .apply (lambda x : x ['a' ], axis = 1 )
100
- tm .assert_frame_equal (xp , rs )
98
+ expected = DataFrame (index = ['a' ])
99
+ result = expected .apply (lambda x : x ['a' ], axis = 1 )
100
+ tm .assert_frame_equal (expected , result )
101
101
102
102
def test_apply_with_reduce_empty (self , empty_frame ):
103
103
# reduce with an empty DataFrame
@@ -126,12 +126,12 @@ def test_apply_deprecate_reduce(self, empty_frame):
126
126
def test_apply_standard_nonunique (self ):
127
127
df = DataFrame (
128
128
[[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]], index = ['a' , 'a' , 'c' ])
129
- rs = df .apply (lambda s : s [0 ], axis = 1 )
130
- xp = Series ([1 , 4 , 7 ], ['a' , 'a' , 'c' ])
131
- tm .assert_series_equal (rs , xp )
129
+ result = df .apply (lambda s : s [0 ], axis = 1 )
130
+ expected = Series ([1 , 4 , 7 ], ['a' , 'a' , 'c' ])
131
+ tm .assert_series_equal (result , expected )
132
132
133
- rs = df .T .apply (lambda s : s [0 ], axis = 0 )
134
- tm .assert_series_equal (rs , xp )
133
+ result = df .T .apply (lambda s : s [0 ], axis = 0 )
134
+ tm .assert_series_equal (result , expected )
135
135
136
136
@pytest .mark .parametrize ('func' , ['sum' , 'mean' , 'min' , 'max' , 'std' ])
137
137
@pytest .mark .parametrize ('args,kwds' , [
@@ -265,13 +265,13 @@ def _check(df, f):
265
265
is_reduction = not isinstance (test_res , np .ndarray )
266
266
267
267
def _checkit (axis = 0 , raw = False ):
268
- res = df .apply (f , axis = axis , raw = raw )
268
+ result = df .apply (f , axis = axis , raw = raw )
269
269
if is_reduction :
270
270
agg_axis = df ._get_agg_axis (axis )
271
- assert isinstance (res , Series )
272
- assert res .index is agg_axis
271
+ assert isinstance (result , Series )
272
+ assert result .index is agg_axis
273
273
else :
274
- assert isinstance (res , DataFrame )
274
+ assert isinstance (result , DataFrame )
275
275
276
276
_checkit ()
277
277
_checkit (axis = 1 )
@@ -298,16 +298,16 @@ def subtract_and_divide(x, sub, divide=1):
298
298
return (x - sub ) / divide
299
299
300
300
result = float_frame .apply (add_some , howmuch = 2 )
301
- exp = float_frame .apply (lambda x : x + 2 )
302
- tm .assert_frame_equal (result , exp )
301
+ expected = float_frame .apply (lambda x : x + 2 )
302
+ tm .assert_frame_equal (result , expected )
303
303
304
304
result = float_frame .apply (agg_and_add , howmuch = 2 )
305
- exp = float_frame .apply (lambda x : x .mean () + 2 )
306
- tm .assert_series_equal (result , exp )
305
+ expected = float_frame .apply (lambda x : x .mean () + 2 )
306
+ tm .assert_series_equal (result , expected )
307
307
308
- res = float_frame .apply (subtract_and_divide , args = (2 ,), divide = 2 )
309
- exp = float_frame .apply (lambda x : (x - 2. ) / 2. )
310
- tm .assert_frame_equal (res , exp )
308
+ result = float_frame .apply (subtract_and_divide , args = (2 ,), divide = 2 )
309
+ expected = float_frame .apply (lambda x : (x - 2. ) / 2. )
310
+ tm .assert_frame_equal (result , expected )
311
311
312
312
def test_apply_yield_list (self , float_frame ):
313
313
result = float_frame .apply (list )
@@ -529,12 +529,12 @@ def test_applymap_box(self):
529
529
'd' : [Period ('2011-01-01' , freq = 'M' ),
530
530
Period ('2011-01-02' , freq = 'M' )]})
531
531
532
- res = df .applymap (lambda x : '{0}' .format (x .__class__ .__name__ ))
533
- exp = DataFrame ({'a' : ['Timestamp' , 'Timestamp' ],
534
- 'b' : ['Timestamp' , 'Timestamp' ],
535
- 'c' : ['Timedelta' , 'Timedelta' ],
536
- 'd' : ['Period' , 'Period' ]})
537
- tm .assert_frame_equal (res , exp )
532
+ result = df .applymap (lambda x : '{0}' .format (x .__class__ .__name__ ))
533
+ expected = DataFrame ({'a' : ['Timestamp' , 'Timestamp' ],
534
+ 'b' : ['Timestamp' , 'Timestamp' ],
535
+ 'c' : ['Timedelta' , 'Timedelta' ],
536
+ 'd' : ['Period' , 'Period' ]})
537
+ tm .assert_frame_equal (result , expected )
538
538
539
539
def test_frame_apply_dont_convert_datetime64 (self ):
540
540
from pandas .tseries .offsets import BDay
0 commit comments