Frequently asked questions#

Can any interval be used with piso?

Unfortunately no. The intervals must

  • have a non-zero length

  • have a finite, length

  • either be left-closed right-open, or right-closed left-open

Operations between Intervals, IntervalIndex and IntervalArray objects must have the same value for their closed attribute.

Are there plans to add support for intervals which are either degenerate (contain a single point), infinite length, or not half-closed?

At this stage no, but this may change depending on the popularity of the package and the demand for this functionality.

Are there existing set operations for intervals in pandas?
Can I work with datetime/timestamp data?

Yes piso will work with pandas.Timestamp and pandas.Timedelta data. Users who wish to use numpy.datetime64 and datetime.datetime (and timedelta counterparts) should be aware that:

Why is there no piso accessor for pandas.Interval?

Objects of type pandas.Interval are immutable, meaning they cannot be changed (incuding the addition of an accessor).

Why use accessors?

Accessors provide a nice way of carving out a seperate namespace for piso, as opposed to monkey patching. This is particularly important for pandas.IntervalIndex, which inherits methods from pandas.Index, which are set based operations:

however these methods consider the elements of the to be the intervals themselves - there is no notion as the intervals being sets.

What if I want to map intervals with a scalar?

This question may arise if, for example, a pandas.Series with a numerical dtype, was indexed with a pandas.IntervalIndex. Given two intervals, and their associated scalar values, a user may wish to find the overlap of these intervals, and map it to the minimum of the two scalar values - or perhaps the addition of the scalar values. These sorts of manipulations can be achieved via staircase. There is a one-to-one mapping between sets of disjoint intervals (with associated scalars) and step functions, which is what motivates the internal implementations of piso. staircase provides a comprehensive range of arithmetic, logical, relational and statistical methods for working with step functions. For related case studies see the football case study with piso and the football case study with staircase