Skip to main content

piso logo

piso - pandas interval set operations

piso exists to bring set operations (union, intersection, difference + more), analytical methods, and lookup and join functionality to pandas' interval classes, specifically

- pandas.Interval
- pandas.arrays.IntervalArray
- pandas.IntervalIndex

Currently, there is a lack of such functionality in pandas, although it has been earmarked for development. Until this eventuates, piso aims to fill the void. Many of the methods can be used via accessors, which can be registered to pandas.arrays.IntervalArray and pandas.IntervalIndex classes, for example:

>>> import pandas as pd
>>> import piso
>>> piso.register_accessors()

>>> arr = pd.arrays.IntervalArray.from_tuples(
...        [(1,5), (3,6), (2,4)]
...    )

>>> arr.piso.intersection()
<IntervalArray>
[(3, 4]]
Length: 1, closed: right, dtype: interval[int64]

>>> arr.piso.contains([2, 3, 5])
            2      3      5
(1, 5]   True   True   True
(3, 6]  False  False   True
(2, 4]  False   True  False

>>> df = pd.DataFrame(
...     {"A":[4,3], "B":["x","y"]},
...     index=pd.IntervalIndex.from_tuples([(1,3), (5,7)]),
... )

>>> s = pd.Series(
...     [True, False],
...     index=pd.IntervalIndex.from_tuples([(2,4), (5,6)]),
...     name="C",
... )

>>> piso.join(df, s)
        A  B      C
(1, 2]  4  x    NaN
(2, 3]  4  x   True
(5, 6]  3  y  False
(6, 7]  3  y    NaN

>>> piso.join(df, s, how="inner")
        A  B      C
(2, 3]  4  x   True
(5, 6]  3  y  False

The domain of the intervals can be either numerical, pandas.Timestamp or pandas.Timedelta.

Several case studies using piso can be found in the user guide. Further examples, and a detailed explanation of functionality, are provided in the API reference.

Visit https://piso.readthedocs.io for the documentation.

Installation

piso can be installed from PyPI or Anaconda.

To install the latest version from PyPI::

python -m pip install piso

To install the latest version through conda-forge::

conda install -c conda-forge piso

Versioning

SemVer is used by piso for versioning releases. For versions available, see the tags on this repository.

License

This project is licensed under the MIT License

Acknowledgments

Currently, piso is a pure-python implentation which relies heavily on staircase and pandas. It is designed to operate as part of the pandas ecosystem. The colours for the piso logo have been assimilated from pandas as a homage, and is not to intended to imply and affiliation with, or endorsement by, pandas.

Additionally, two classes have been borrowed, almost verbatim, from the pandas source code:

- `pandas.util._decorators.Appender`
- `pandas.core.accessor.CachedAccessor`

Metadata

Release files for piso 1.3.0

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

Source distribution (sdist)

Source distribution for piso 1.3.0
File Size Uploaded
piso-1.3.0.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for piso 1.3.0
File Interpreter ABI Platform
piso-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.2 kB

Release files / piso-1.3.0.tar.gz

Download URL piso-1.3.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cde376e45b1a5e3620eede3e0af7681f1049492298e5817cb4174f6c29864d6d
BLAKE2b-256 checksum
How to use checksums
f26a01cd2438f2a7832125761d988878e2636f5e3dcb1ba018c7361f75328a1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / piso-1.3.0-py3-none-any.whl

Download URL piso-1.3.0-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d909bb5511a07e1412490f188e80c5a3e203005474b3b73d41914e3776fa90c1
BLAKE2b-256 checksum
How to use checksums
3f7a20abf6724febe1517c306c74c207f7ad2b694ad89bf6236f15489bfdaf7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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