from scipy import integrate
x = np.linspace(-2, 2, num=20)
y = x
y_int = integrate.cumtrapz(y, x, initial=0)
plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x ** 2, 'b-')
How do I integrate two 1-D data arrays in Python?