Skip to main content

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 The shift argument determines the number of input elements by which the window moves on each iteration. Defaults to size.
  • stride? int=1 Determines the stride of the input elements. Defaults to 1.

Returns np.ndarray

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get-rolling-window-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

get_rolling_window-1.0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file get-rolling-window-1.0.0.tar.gz.

File metadata

  • Download URL: get-rolling-window-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for get-rolling-window-1.0.0.tar.gz
Algorithm Hash digest
SHA256 477c83d2bc1e986e39038cff2362b7831dd6e669efe2450ca9534ea6715cc5aa
MD5 a4f970b435ba33de3961c57dfabd4015
BLAKE2b-256 bc7dcdc716cd69c5d6900e721885eccd15b55415c30e6f70ef12d79805bf7321

See more details on using hashes here.

File details

Details for the file get_rolling_window-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: get_rolling_window-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for get_rolling_window-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb030aead7784c93fc431ea4c8f4afbee12a2f30d18ad31a57161da19cfd416b
MD5 cd9b85cd8ea2efca3ce199cc7ffcc02c
BLAKE2b-256 c552a4a312e7d1595545843a04810fd4059b4267afc2eafd0e0cd073567e7524

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page