Window Operations

0.0.15 · active · verified Sun Apr 12

The `window-ops` library provides optimized implementations of window operations such as rolling and expanding functions. It aims to offer a significant speedup over `pandas.Series.rolling` and `pandas.Series.expanding` by utilizing Numba-optimized functions that operate on NumPy arrays. The library also includes 'online' classes for efficiently updating window statistics as new data arrives. It is currently in an alpha development stage (0.0.15), with releases as features are added or improved.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `window-ops` to compute rolling and expanding means on a NumPy array. The functions directly operate on NumPy arrays for performance benefits.

import numpy as np
from window_ops.rolling import rolling_mean
from window_ops.expanding import expanding_mean

data = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])

# Calculate rolling mean with a window size of 3
rolling_result = rolling_mean(data, window_size=3)
print(f"Original data: {data}")
print(f"Rolling mean (window=3): {rolling_result}")

# Calculate expanding mean
expanding_result = expanding_mean(data)
print(f"Expanding mean: {expanding_result}")

view raw JSON →