NumPy Extensions
An extension library for NumPy that implements common array operations not present in NumPy.
npext.fill_na(...)npext.drop_na(...)npext.rolling(...)npext.expanding(...)npext.rolling_apply(...)npext.expanding_apply(...)# etc
Documentation
Installation
Regular installation:
pip install numpy_ext
For development:
git clone https://github.com/3jane/numpy_ext.git
cd numpy_ext
pip install -e .[dev] # note: make sure you are using pip>=20
Examples
Here are few common examples of how the library is used. The rest is available in the documentation.
- Apply a function to a rolling window over the provided array
import numpy as np
import numpy_ext as npext
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
window = 3
npext.rolling_apply(np.sum, window, a)
> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.])
- Same as the above, but with a custom function, two input arrays and parallel computation using
joblib:
def func(array_first, array_second, param):
return (np.min(array_first) + np.sum(array_second)) * param
a = np.array([0, 1, 2, 3])
b = np.array([3, 2, 1, 0])
npext.rolling_apply(func, 2, a, b, n_jobs=2, param=-1)
> array([nan, -5., -4., -3.])
- Same as the first example, but using rolling function:
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
window = 3
rolls = npext.rolling(a, window, as_array=True)
np.sum(rolls, axis=1)
> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.])
- Apply a function with multiple output to a rolling window over the provided array, with no nans prepend
res = npext.rolling_apply(
lambda x: (max(x), min(x)),
3,
np.array([1, 2, 5, 1, 6, 4, 0]),
prepend_nans=False,
)
> array([[5, 1],
[5, 1],
[6, 1],
[6, 1],
[6, 0]])
License
The software is distributed under MIT license.
Metadata
Release files for numpy-ext 0.9.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| numpy_ext-0.9.9.tar.gz | 6.9 kB | Without provenance | Details for numpy_ext-0.9.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| numpy_ext-0.9.9-py3-none-any.whl | Python 3 | none | any | Details for numpy_ext-0.9.9-py3-none-any.whl |
Total release size: 14.1 kB
Release files / numpy_ext-0.9.9.tar.gz
| Download URL | numpy_ext-0.9.9.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f60f2b03f9279b89387f1e25946a931c03f4880cc35099421b6eeb37eaa0f92
|
|
BLAKE2b-256 checksum How to use checksums |
55f18419bed8365d6d2022b8986f27a7a3b382e2bc3fdc41955cd3bd1f18208b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|
Release files / numpy_ext-0.9.9-py3-none-any.whl
| Download URL | numpy_ext-0.9.9-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f0cdab47de649042691137a75e18801393b60c8d2191f39aad51af850eb65a1
|
|
BLAKE2b-256 checksum How to use checksums |
c787df82011766c011ab3fe2829ed32b352455fc845026cade9e162bdbf4a918
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|
Security for numpy-ext 0.9.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.