pandas-accumulate: accumulate values along Pandas series
This package provides one function that allows accumulating values along a
Pandas series very similar to cumsum and cumprod but allowing also other
operators like |.
Usage examples
cumsum
Replicate cumsum:
>>> import operator
>>> import pandas as pd
>>> from pandas_accumulate import accumulate
>>> s = pd.Series([1, 2, 3])
>>> accumulate(s, operator.add)
0 1
1 3
2 6
dtype: int64
cumulative unique()
Collect the unique values cumulatively. Note: You need to pass an
initial value for the accumulation in this example:
>>> s = pd.Series([1,2,1,3,2])
>>> def f(acc, v):
... return acc | {v}
>>> accumulate(s, f, initial=set())
0 {1}
1 {1, 2}
2 {1, 2}
3 {1, 2, 3}
4 {1, 2, 3}
dtype: object
cumulative nunique()
If you're interested only in the number of unique values, just call len at
the end:
>>> accumulate(s, f, initial=set()).map(len)
0 1
1 2
2 2
3 3
4 3
dtype: int64
Metadata
Release files for pandas-accumulate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pandas_accumulate-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pandas_accumulate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / pandas_accumulate-0.1.0.tar.gz
| Download URL | pandas_accumulate-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
985ca6c1cf25dc8bd6ebdc745e706f03cb8cdeba4539edd871f09dc5387b1a22
|
|
BLAKE2b-256 checksum How to use checksums |
52a38d1eff98e5a4a5a6f347aec22f4454819077dca46076f086f643d8b0710b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / pandas_accumulate-0.1.0-py3-none-any.whl
| Download URL | pandas_accumulate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6a84d1a2f08b9cb07a42124e46cccc93350fe1542637d6fad607d1b4c7dd33e
|
|
BLAKE2b-256 checksum How to use checksums |
225e178709cce4570bd19a0165ab7b1fa56eb859ab84d627d01776f00c646cd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|