piso.accessor.ArrayAccessor.split#
- ArrayAccessor.split(x)#
Given a set of intervals, and break points, splits the intervals into pieces wherever the overlap a break point.
The intervals are contained in the object the accessor belongs to. They may be left-closed, right-closed, both, or neither, and contain overlapping intervals.
- Parameters
- xscalar, or array-like of scalars
Values in x should belong to the same domain as the intervals in interval_array. May contain duplicates and be unsorted.
- Returns
pandas.IntervalIndex
orpandas.arrays.IntervalArray
Return type will be the same type as the object the accessor belongs to.
Examples
>>> import pandas as pd >>> import piso >>> piso.register_accessors()
>>> arr = pd.arrays.IntervalArray.from_tuples( ... [(0, 4), (2, 5)], ... )
>>> arr.piso.split(3) <IntervalArray> [(0, 3], (3, 4], (2, 3], (3, 5]] Length: 4, closed: right, dtype: interval[int64]
>>> arr.piso.split([3,3,3,3]) <IntervalArray> [(0, 3], (3, 4], (2, 3], (3, 5]] Length: 4, closed: right, dtype: interval[int64]
>>> arr = pd.IntervalIndex.from_tuples( ... [(0, 4), (2, 5)], closed="neither", ... )
>>> arr.piso.split([1, 6, 4]) IntervalIndex([(0.0, 1.0), (1.0, 4.0), (2.0, 4.0), (4.0, 5.0)], closed='neither', dtype='interval[float64]')