Skip to main content

No project description provided

Project description

cougar

A python C-extension for rolling window aggregations. Try to support more methods than bottleneck and run faster than pandas. Currently this is only a weekend project, feel free to contribute.

Installation

pip install cougar

Usage

>>> import numpy as np
>>> import cougar as cg


>>> arr = np.random.randn(8)
>>> arr
array([-2.31572505, -1.78462521,  0.17355123,  0.77365821,  0.81431295,
        1.56188616,  0.74933881,  0.06184727])
>>> cg.rolling_mean(arr, 3)
array([        nan,         nan, -1.30893301, -0.27913859,  0.58717413,
        1.04995244,  1.04184597,  0.79102408])
>>> cg.rolling_rank(arr, 5, min_count=1)
array([ 0. ,  1. ,  1. ,  1. ,  1. ,  1. , -0.5, -1. ])

Supported Methods

Method Time Complexity
sum $O(1)$
mean $O(1)$
std $O(1)$
var $O(1)$
skew $O(1)$
kurt $O(1)$
min $O(1)$
max $O(1)$
argmin $O(1)$
argmax $O(1)$
median $O(\log n)$
rank $O(\log n)$
quantile $O(\log n)$

Benchmark

python benchmark.py
            Cougar vs. Bottleneck             
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Method       ┃ Cougar       ┃ Bottleneck   ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ sum          │ 2.99         │ 1.00         │
│ mean         │ 3.08         │ 1.00         │
│ std          │ 2.10         │ 1.00         │
│ var          │ 2.15         │ 1.00         │
│ max          │ 2.84         │ 1.00         │
│ min          │ 1.23         │ 1.00         │
│ argmax       │ 1.40         │ 1.00         │
│ argmin       │ 1.16         │ 1.00         │
│ median       │ 1.33         │ 1.00         │
│ rank         │ 1.00         │ 15.02        │
└──────────────┴──────────────┴──────────────┘

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

cougar-0.5.13.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distributions

cougar-0.5.13-cp311-cp311-win_amd64.whl (49.5 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

cougar-0.5.13-cp311-cp311-manylinux1_x86_64.whl (269.2 kB view hashes)

Uploaded CPython 3.11

cougar-0.5.13-cp311-cp311-macosx_10_9_universal2.whl (82.3 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

cougar-0.5.13-cp310-cp310-win_amd64.whl (49.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

cougar-0.5.13-cp310-cp310-manylinux1_x86_64.whl (268.4 kB view hashes)

Uploaded CPython 3.10

cougar-0.5.13-cp310-cp310-macosx_11_0_x86_64.whl (53.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ x86-64

cougar-0.5.13-cp39-cp39-win_amd64.whl (49.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

cougar-0.5.13-cp39-cp39-manylinux1_x86_64.whl (268.0 kB view hashes)

Uploaded CPython 3.9

cougar-0.5.13-cp39-cp39-macosx_11_0_x86_64.whl (53.5 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

cougar-0.5.13-cp38-cp38-win_amd64.whl (49.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

cougar-0.5.13-cp38-cp38-manylinux1_x86_64.whl (269.5 kB view hashes)

Uploaded CPython 3.8

cougar-0.5.13-cp38-cp38-macosx_11_0_x86_64.whl (53.5 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

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