fastgrouper
Allows for fast groupby-apply operations, in python.
Install
Users can install the package from PyPI via:
python -m pip install fastgrouper
Usage
Use the arr interface, for numpy array focused applications.
import numpy as np
import fastgrouper.arr
def baz(x, y):
return np.mean(x + y) - 3
# Sample arrays, to slice
xvals = np.array([1, 2, 10])
yvals = np.array([4, 5, 6])
# Group ids
gids = np.array([1, -3, 1])
# Perform groupby-apply; note that keyword args are supported as well.
grpd = fastgrouper.arr.Grouped(gids)
result = grpd.apply(baz, xvals, y=yvals) # np.array([7.5, 4])
# The gids correponding to the result above can be found via the `dedup_gids` attribute.
grpd.dedup_gids # np.array([ 1, -3])
# Users can also perform groupby-apply, and then expand results back to align with the original gids.
result = grpd.apply_expand(baz, xvals, yvals) # np.array([7.5, 4, 7.5])
The li interface returns the results over the groups as a list (instead of an array); this may be useful for functions that return different-sized results. Note that in all interfaces (e.g. both arr and li), the order in which the group elements appear is preserved when the group slices are passed to the function being applied.
import numpy as np
import fastgrouper.li
def bop(x):
return list(x)
# Sample arrays, to slice
xvals = np.array([2, 3, 4])
# Group ids
gids = np.array([10, -20, 10])
grpd = fastgrouper.li.Grouped(gids)
grpd.apply(bop, xvals) # [[2, 4], [3]]
For additional examples, checkout the tests.
Metadata
Release files for fastgrouper 0.1.2
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 |
|---|---|---|---|---|
| fastgrouper-0.1.2.tar.gz | 5.2 kB | Without provenance | Details for fastgrouper-0.1.2.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastgrouper-0.1.2-py3.8.egg | Legacy Egg format | - | - | Details for fastgrouper-0.1.2-py3.8.egg |
| fastgrouper-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for fastgrouper-0.1.2-py3-none-any.whl |
Total release size: 21.6 kB
Release files / fastgrouper-0.1.2.tar.gz
| Download URL | fastgrouper-0.1.2.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d90b2cd98a2f8bd6dc3cddc8aa32fa5f58b68b902a2e20c2f747f353068fcb11
|
|
BLAKE2b-256 checksum How to use checksums |
4b3dee75e9c42a6b54c5b28b86503b4cfe912bba3926e3010e105dceb8ce27d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.8
|
Release files / fastgrouper-0.1.2-py3.8.egg
| Download URL | fastgrouper-0.1.2-py3.8.egg |
|---|---|
| Size | 10.3 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
0fe8e7b3a9544a54fb94c1b5e31a54947a878bcdee0d6adb74701d5a6f8ee43b
|
|
BLAKE2b-256 checksum How to use checksums |
e73b543b7d5843a7d32e7096474a094a9cd34c2a25dcd32c1c5a23c045600ecc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.8
|
Release files / fastgrouper-0.1.2-py3-none-any.whl
| Download URL | fastgrouper-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01ec249a2871d8a5b11c76d37dbb2e51c120b627c5e9864452ad9f0a15d3e95f
|
|
BLAKE2b-256 checksum How to use checksums |
480ffd795181bb60d9f58ca58d6115ed7f4f6156320154b2be3330af1e9c758e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.8
|
Security for fastgrouper 0.1.2
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.