NumPy offers several window options that can compute weights in a rolling window as we did in the previous section.
The window function uses an interval for spectral analysis and filter design (for more background information, refer to http://en.wikipedia.org/wiki/Window_function). The boxcar window is a rectangular window with the following formula:
w(n) = 1
The triangular window is shaped like a triangle and has the following formula:
![](https://static.packt-cdn.com/products/9781789955248/graphics/assets/ec4ec393-f982-43b3-a864-1d7a1e8817a7.png)
Here, L can be equal to N, N+1, or N–1.
If the value of L is N–1, it is known as the Bartlett window and has the following formula:
![](https://static.packt-cdn.com/products/9781789955248/graphics/assets/715dfe5d-e6dc-4d40-899a-ab61d45b9d98.png)
![](https://static.packt-cdn.com/products/9781789955248/graphics/assets/aaf1be2b-80d5-491c-89aa-42eaf91bb297.png)
In the pandas module, the DataFrame.rolling() function provides the same functionality using the win_type parameter for different window functions. Another parameter is the window for defining the size of the window, which is easy to set as shown in the previous...