A = np.random.randn(10)
a = 2.0
b = 3.0
B = lfilter([a], [1, -b], A)
print(B)
B2 = np.empty(len(A))
for k in range(0, len(B2)):
    if k == 0:
        B2[k] = a * A[k]
else:
    B2[k] = a * A[k] + b * B2[k - 1]
print(B2)
print('max difference:', np.max(np.abs(B2 - B)))
Recursive definitions in Pandas