piso.issubset#

piso.issubset(interval_array, *interval_arrays, squeeze=True)#

Indicates whether a set is a subset of one, or more, other sets.

The argument interval_array and the array elements of interval_arrays are all considered to be the sets for the purposes of this set method. Each of these arrays is assumed to contain disjoint intervals (and satisfy the definition of a set). Any array containing overlaps between intervals will be mapped to one with disjoint intervals via a union operation.

The list interval_arrays must contain at least one element. The subset comparison is iteratively applied between interval_array and each array in interval_arrays. When interval_arrays contains multiple interval arrays, the return type will be a numpy array. If it contains one interval array then the result can be coerced to a single boolean using the squeeze parameter.

Parameters
interval_arraypandas.IntervalIndex or pandas.arrays.IntervalArray

The first operand to which all others are compared operation.

*interval_arraysargument list of pandas.IntervalIndex or pandas.arrays.IntervalArray

Must contain at least one argument.

squeezeboolean, default True

If True, will try to coerce the return value to a single pandas.Interval. If supplied, must be done so as a keyword argument.

Returns
boolean, or numpy.ndarray of boolean

Examples

>>> import pandas as pd
>>> import piso
>>> arr1 = pd.arrays.IntervalArray.from_tuples(
...     [(2, 5), (7, 8)],
... )
>>> arr2 = pd.arrays.IntervalArray.from_tuples(
...     [(0, 4), (3, 6), (7, 8), (10, 12)],
... )
>>> arr3 = pd.arrays.IntervalArray.from_tuples(
...     [(3, 4), (10, 11)],
... )
>>> piso.issubset(arr1, arr2)
True
>>> piso.issubset(arr1, arr2, squeeze=False)
array([ True])
>>> piso.issubset(arr1, arr2, arr3)
array([ True, False])
>>> piso.issubset(arr1, arr3)
False