piso.accessor.ArrayAccessor.issubset#
- ArrayAccessor.issubset(*interval_arrays, squeeze=False)#
Indicates whether a set is a subset 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 subset 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
orpandas.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.
- *interval_arraysargument list of
- Returns
Examples
>>> import pandas as pd >>> import piso >>> piso.register_accessors()
>>> 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)], ... )
>>> arr1.piso.issubset(arr2) True
>>> arr1.piso.issubset(arr2, squeeze=False) array([ True])
>>> arr1.piso.issubset(arr2, arr3) array([ True, False])
>>> arr1.piso.issubset(arr3) False