panelexpr
A simple panel data evaluator
Installation
$ pip install panelexpr
Usage
Sample Data
sample_zh_2.csv:
| Date | windcode | Open | High | Low | Close | Volume |
|---|---|---|---|---|---|---|
| 20170913 | 000001.SZ | 1221.488009 | 1226.803448 | 1205.54169 | 1215.109481 | 668237.42 |
| 20170914 | 000001.SZ | 1215.109481 | 1232.118888 | 1194.910811 | 1203.415514 | 883087.77 |
| 20170915 | 000001.SZ | 1200.22625 | 1203.415514 | 1185.34302 | 1200.22625 | 646094.81 |
| 20170918 | 000001.SZ | 1195.973899 | 1203.415514 | 1190.658459 | 1195.973899 | 607612.96 |
| 20170919 | 000001.SZ | 1195.973899 | 1205.54169 | 1177.901404 | 1183.216844 | 764212.62 |
| 20170913 | 000002.SZ | 3473.691392 | 3576.666433 | 3431.128374 | 3536.849417 | 467463.77 |
| 20170914 | 000002.SZ | 3539.595418 | 3852.639543 | 3508.016405 | 3783.989516 | 1150696.14 |
| 20170915 | 000002.SZ | 3775.751513 | 4149.207662 | 3771.632511 | 4022.891612 | 1550495.61 |
| 20170918 | 000002.SZ | 3983.074596 | 4083.303636 | 3843.028539 | 3849.893542 | 1063043.07 |
| 20170919 | 000002.SZ | 3881.472555 | 4132.731656 | 3858.131546 | 3950.122582 | 1196308.5 |
load data
import pandas as pd
data = pd.read_csv("../data/sample_zh_2.csv")
Calculation
import panelexpr as pe
pe.eval("ma(Open, 2)", data=data, group_tag="windcode")
# equivalent to
data.groupby("windcode").rolling(2).mean()["Open"].reset_index(drop=True).rename()
Output:
0 NaN
1 1218.298745
2 1207.667866
3 1198.100075
4 1195.973899
5 NaN
6 3506.643405
7 3657.673466
8 3879.413054
9 3932.273575
dtype: float64
User defined operator
from panelexpr import TimeSeriesOperator
class MyMovingAverageOperator(TimeSeriesOperator):
def eval(self, series: pd.Series, window) -> pd.Series: # all udo must implement this method
s = series.rolling(window).mean()
return s
pe.register("my_ma", MyMovingAverageOperator) # register the operator
pe.eval("my_ma(Open, 2)", data=data, group_tag="windcode")
Metadata
Release files for panelexpr 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 | Provenance | Actions |
|---|---|---|---|---|
| panelexpr-0.1.0.tar.gz | 11.6 kB | Without provenance | Details for panelexpr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| panelexpr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for panelexpr-0.1.0-py3-none-any.whl |
Total release size: 24.9 kB
Release files / panelexpr-0.1.0.tar.gz
| Download URL | panelexpr-0.1.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb04d58abba8ad0db72365b99f42227d1012608fc9ec5ce3c26140d29fb74d60
|
|
BLAKE2b-256 checksum How to use checksums |
db51198d88a397f35ca2421c4217b046a061edfafd1b12576c28197148203d27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3
|
Release files / panelexpr-0.1.0-py3-none-any.whl
| Download URL | panelexpr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19a77b641799c44208b950f14dfe1b0a7c526e1ef64babd816b051bb279682d9
|
|
BLAKE2b-256 checksum How to use checksums |
40f5bd35bdf5ea53b07e44d4549536865f6c66f412416d9881ae5ec0c99712b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3
|
Security for panelexpr 0.1.0
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.