Skip to content

Commit 30f1b7d

Browse files
committed
Clean res/exp in frame/test_apply.py
1 parent fc03739 commit 30f1b7d

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

pandas/tests/frame/test_apply.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def test_apply_empty(self, float_frame, empty_frame):
9595
tm.assert_series_equal(result, expected)
9696

9797
# 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)
101101

102102
def test_apply_with_reduce_empty(self, empty_frame):
103103
# reduce with an empty DataFrame
@@ -126,12 +126,12 @@ def test_apply_deprecate_reduce(self, empty_frame):
126126
def test_apply_standard_nonunique(self):
127127
df = DataFrame(
128128
[[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)
132132

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)
135135

136136
@pytest.mark.parametrize('func', ['sum', 'mean', 'min', 'max', 'std'])
137137
@pytest.mark.parametrize('args,kwds', [
@@ -265,13 +265,13 @@ def _check(df, f):
265265
is_reduction = not isinstance(test_res, np.ndarray)
266266

267267
def _checkit(axis=0, raw=False):
268-
res = df.apply(f, axis=axis, raw=raw)
268+
result = df.apply(f, axis=axis, raw=raw)
269269
if is_reduction:
270270
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
273273
else:
274-
assert isinstance(res, DataFrame)
274+
assert isinstance(result, DataFrame)
275275

276276
_checkit()
277277
_checkit(axis=1)
@@ -298,16 +298,16 @@ def subtract_and_divide(x, sub, divide=1):
298298
return (x - sub) / divide
299299

300300
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)
303303

304304
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)
307307

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)
311311

312312
def test_apply_yield_list(self, float_frame):
313313
result = float_frame.apply(list)
@@ -529,12 +529,12 @@ def test_applymap_box(self):
529529
'd': [Period('2011-01-01', freq='M'),
530530
Period('2011-01-02', freq='M')]})
531531

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)
538538

539539
def test_frame_apply_dont_convert_datetime64(self):
540540
from pandas.tseries.offsets import BDay

0 commit comments

Comments
 (0)