piso.accessor.ArrayAccessor.issuperset#

ArrayAccessor.issuperset(*interval_arrays, squeeze=False)#

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

The array elements of interval_arrays, and the interval array object the accessor belongs to (an instance of pandas.IntervalIndex, pandas.arrays.IntervalArray) are considered to be the sets over which the operation is performed. 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 superset comparison is iteratively applied between the interval array the accessor belongs to, 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_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
pandas.IntervalIndex or pandas.arrays.IntervalArray

Examples

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