pandasmore
The full documentation site is here, and the GitHub page is here.
Here is a short description of some of the main functions (more details below and in the documentation):
setup_tseries: cleans up dates and sets them as the indexsetup_panel: cleans up dates and panel id’s and sets them as the index (panel id, period date)lag: robust lagging that accounts for panel structure, unsorted or duplicate dates, or gaps in the time-series
Install
pip install pandasmore
How to use
First, we set up an example dataset to showcase the functions in this module.
import pandas as pd
import numpy as np
import pandasmore as pdm
raw = pd.DataFrame(np.random.rand(15,2),
columns=list('AB'),
index=pd.MultiIndex.from_product(
[[1,2, np.nan],[np.nan,'2010-01','2010-02','2010-02','2010-04']],
names = ['firm_id','date'])
).reset_index()
raw
| firm_id | date | A | B | |
|---|---|---|---|---|
| 0 | 1.0 | NaN | 0.249370 | 0.926335 |
| 1 | 1.0 | 2010-01 | 0.282501 | 0.513859 |
| 2 | 1.0 | 2010-02 | 0.804278 | 0.307171 |
| 3 | 1.0 | 2010-02 | 0.828895 | 0.746789 |
| 4 | 1.0 | 2010-04 | 0.569099 | 0.331814 |
| 5 | 2.0 | NaN | 0.533977 | 0.823457 |
| 6 | 2.0 | 2010-01 | 0.207558 | 0.401378 |
| 7 | 2.0 | 2010-02 | 0.086001 | 0.959371 |
| 8 | 2.0 | 2010-02 | 0.054230 | 0.993980 |
| 9 | 2.0 | 2010-04 | 0.062525 | 0.200272 |
| 10 | NaN | NaN | 0.091012 | 0.635409 |
| 11 | NaN | 2010-01 | 0.866369 | 0.972394 |
| 12 | NaN | 2010-02 | 0.432087 | 0.837597 |
| 13 | NaN | 2010-02 | 0.878219 | 0.148009 |
| 14 | NaN | 2010-04 | 0.820386 | 0.834821 |
df = pdm.setup_tseries(raw.query('firm_id==1'),
time_var='date', time_var_format="%Y-%m",
freq='M')
df
| date | dtdate | firm_id | A | B | |
|---|---|---|---|---|---|
| Mdate | |||||
| 2010-01 | 2010-01 | 2010-01-01 | 1.0 | 0.282501 | 0.513859 |
| 2010-02 | 2010-02 | 2010-02-01 | 1.0 | 0.828895 | 0.746789 |
| 2010-04 | 2010-04 | 2010-04-01 | 1.0 | 0.569099 | 0.331814 |
df = pdm.setup_panel(raw,
panel_ids='firm_id',
time_var='date', time_var_format="%Y-%m",
freq='M')
df
| date | dtdate | A | B | ||
|---|---|---|---|---|---|
| firm_id | Mdate | ||||
| 1 | 2010-01 | 2010-01 | 2010-01-01 | 0.282501 | 0.513859 |
| 2010-02 | 2010-02 | 2010-02-01 | 0.828895 | 0.746789 | |
| 2010-04 | 2010-04 | 2010-04-01 | 0.569099 | 0.331814 | |
| 2 | 2010-01 | 2010-01 | 2010-01-01 | 0.207558 | 0.401378 |
| 2010-02 | 2010-02 | 2010-02-01 | 0.054230 | 0.993980 | |
| 2010-04 | 2010-04 | 2010-04-01 | 0.062525 | 0.200272 |
pdm.lag(df['A'])
firm_id Mdate
1 2010-01 NaN
2010-02 0.282501
2010-04 NaN
2 2010-01 NaN
2010-02 0.207558
2010-04 NaN
Name: A_lag1, dtype: float64
Metadata
Release files for pandasmore 0.0.7
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 |
|---|---|---|---|---|
| pandasmore-0.0.7.tar.gz | 26.2 kB | Without provenance | Details for pandasmore-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandasmore-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for pandasmore-0.0.7-py3-none-any.whl |
Total release size: 38.3 kB
Release files / pandasmore-0.0.7.tar.gz
| Download URL | pandasmore-0.0.7.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1077d222ebb57b222d37f69d59de97343c6326ff0d954400598096272ac10c96
|
|
BLAKE2b-256 checksum How to use checksums |
737464b67a5a745d9b2d0021f9e6d084065d18d6660ef5f2edd0e94b6041172c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / pandasmore-0.0.7-py3-none-any.whl
| Download URL | pandasmore-0.0.7-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
784510037b1582257ec4f4bad673764b572d040a01f97e9716f89bfc83c16518
|
|
BLAKE2b-256 checksum How to use checksums |
bb95e35d69d9368a2bc0d7fd705bcbb0628807f35384a552403d78e3424af87d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for pandasmore 0.0.7
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.