piso icon indicating copy to clipboard operation
piso copied to clipboard

ENH: Support for both close

Open PaleNeutron opened this issue 2 years ago • 6 comments

Is your feature request related to a problem?

import pandas as pd
import piso
piso.register_accessors()
arr = pd.arrays.IntervalArray.from_tuples(
       [(1,5), (3,6), (2,4)], closed="both")
 
arr.piso.intersection()

Describe the solution you'd like

[[3, 4]]

In interval computation closed interval is a quite normal case, can you support that?

PaleNeutron avatar Nov 07 '22 08:11 PaleNeutron

Hi John, thanks for the interest.

Piso is intended to be a stop-gap until Pandas implements similar functionality. Under the hood, piso uses Staircase to perform a lot of operations, and this approach only facilitates half-open intervals. Adding the functionality for closed, or open intervals would require a complete rewrite to move away from Staircase and towards another approach - likely Interval Trees written in C code. As such it will remain out of scope for this project.

venaturum avatar Nov 08 '22 02:11 venaturum

Thanks for reply! Does pandas already milestone similar functions?

PaleNeutron avatar Nov 08 '22 02:11 PaleNeutron

Not milestoned, but an open Issue.

I don't expect it will be actioned soon, I suspect it would require significant development to do properly.

venaturum avatar Nov 08 '22 08:11 venaturum

The docs for piso.bridge say that 'both' and 'neither' are accepted:

https://piso.readthedocs.io/en/latest/reference/api/piso.bridge.html

Can we get that updated please?

marade avatar Jun 07 '24 22:06 marade

Thanks for pointing that out @marade, will sort out by the end of the month when a new package is released.

venaturum avatar Jun 08 '24 01:06 venaturum

Thanks. I've found piso to be very useful. I wish pandas would adopt these features and others for Intervals.

marade avatar Jun 08 '24 16:06 marade