CLN: replace lambdas with defs · pandas-dev/pandas@5cf4957 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -3176,7 +3176,8 @@ def apply(self, func, convert_dtype=True, args=(), **kwds):
3176 3176
3177 3177 # handle ufuncs and lambdas
3178 3178 if kwds or args and not isinstance(func, np.ufunc):
3179 -f = lambda x: func(x, *args, **kwds)
3179 +def f(x):
3180 +return func(x, *args, **kwds)
3180 3181 else:
3181 3182 f = func
3182 3183
Original file line number Diff line number Diff line change
@@ -99,7 +99,8 @@ def test_where_array_like(self):
99 99 cond = [False, True]
100 100
101 101 for klass in klasses:
102 -f = lambda: i.where(klass(cond))
102 +def f():
103 +return i.where(klass(cond))
103 104 pytest.raises(NotImplementedError, f)
104 105
105 106 def test_repeat(self):
@@ -2415,7 +2416,8 @@ def check(nlevels, with_nulls):
2415 2416
2416 2417 # with a dup
2417 2418 if with_nulls:
2418 -f = lambda a: np.insert(a, 1000, a[0])
2419 +def f(a):
2420 +return np.insert(a, 1000, a[0])
2419 2421 labels = list(map(f, labels))
2420 2422 index = MultiIndex(levels=levels, labels=labels)
2421 2423 else: