Create a rolling window from a 1-D numpy ndarray
Project description
get-rolling-window
Gets an array of size
-period rolling windows from an numpy 1-D array
Install
$ pip install get-rolling-window
Usage
import numpy as np
from get_rolling_window import rolling_window
array = np.arange(1, 8)
rolling_window(array, 3, 2)
# array([[1, 2, 3],
# [3, 4, 5],
# [5, 6, 7]])
rolling_window(array, size, shift, stride) -> np.ndarray
|-------- size:3 --------|
|- stride:1 -| |
| | |
1 2 3 --------|---
shift:2
3 4 5 --------|---
5 6 7
- array
np.ndarray
The 1-D numpy array. If the given array has more than one dimensions, it will be treated as a 1-D array. - size
int
The size of the window. - shift?
int=None
Theshift
argument determines the number of input elements by which the window moves on each iteration. Defaults tosize
. - stride?
int=1
Determines the stride of the input elements. Defaults to1
.
Returns np.ndarray
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for get_rolling_window-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb030aead7784c93fc431ea4c8f4afbee12a2f30d18ad31a57161da19cfd416b |
|
MD5 | cd9b85cd8ea2efca3ce199cc7ffcc02c |
|
BLAKE2b-256 | c552a4a312e7d1595545843a04810fd4059b4267afc2eafd0e0cd073567e7524 |