pandas.arrays.IntervalArray.from_breaks#
- classmethod IntervalArray.from_breaks(breaks, closed='right', copy=False, dtype=None)[source]#
Construct an IntervalArray from an array of splits.
This method creates intervals from consecutive pairs of break points, where each break point is the right edge of one interval and the left edge of the next.
- Parameters:
- breaksarray-like (1-dimensional)
Left and right bounds for each interval.
- closed{‘left’, ‘right’, ‘both’, ‘neither’}, default ‘right’
Whether the intervals are closed on the left-side, right-side, both or neither.
- copybool, default False
Copy the data.
- dtypedtype or None, default None
If None, dtype will be inferred.
- Returns:
- IntervalArray
See also
interval_rangeFunction to create a fixed frequency IntervalIndex.
IntervalArray.from_arraysConstruct from a left and right array.
IntervalArray.from_tuplesConstruct from a sequence of tuples.
Examples
>>> pd.arrays.IntervalArray.from_breaks([0, 1, 2, 3]) <IntervalArray> [(0, 1], (1, 2], (2, 3]] Length: 3, dtype: interval[int64, right]