Skip to main content

pandas-context

Provides context to your data, allowing you to make complex slicing around a specific index.

Here's an example:

>>> import pandas as pd
... import numpy as np
... import pandas_context
... n = 1000   # long data
... data = np.random.randn(n)
... index = pd.date_range("19990101", periods=n)
... df = pd.DataFrame(data=data, index=index)
... date = index[50]

>>> date
Timestamp('1999-02-20 00:00:00', freq='D')

>>> df.context(date)
                   0
1999-02-18  1.086181
1999-02-19  0.174156
1999-02-20 -0.762305  # <-----
1999-02-21 -0.110677
1999-02-22 -0.766751

>>> df.context(date, around=1)
                   0
1999-02-19  0.174156
1999-02-20 -0.762305  # <-----
1999-02-21 -0.110677

>>> df.context(date, pre=3, post=1)
                   0
1999-02-17 -0.809791
1999-02-18  1.086181
1999-02-19  0.174156
1999-02-20 -0.762305  # <-----
1999-02-21 -0.110677

Installation

pip install git+https://github.com/mmngreco/pandas-context

Developers

git clone https://github.com/mmngreco/pandas-context
pip install -e ./pandas-context

Release files for pandas-context 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandas-context 0.0.2
File Size Uploaded
pandas-context-0.0.2.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-context 0.0.2
File Interpreter ABI Platform
pandas_context-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / pandas-context-0.0.2.tar.gz

Download URL pandas-context-0.0.2.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
637a31de9ff2d63f683fc87e70cb52dd981a81debc68e869bf82f663e1499c39
BLAKE2b-256 checksum
How to use checksums
4a47de9c9778cc56fa04d816b1248cab411c0851d505b440488bd0c3cf7ab8cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release files / pandas_context-0.0.2-py3-none-any.whl

Download URL pandas_context-0.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1955ab0c3da722e1c4763e342587dca2c99300076fdb9c49171b34a72a7c8d1d
BLAKE2b-256 checksum
How to use checksums
61940e472db793ee84c6e180af8b6d2983916a11094d67ea8112c5fe8ab8e920
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page