- API reference
- pandas.arrays.IntervalArray
- pandas.array...
pandas.arrays.IntervalArray.from_arrays#
- classmethodIntervalArray.from_arrays(left,right,closed='right',copy=False,dtype=None)[source]#
Construct from two arrays defining the left and right bounds.
- Parameters:
- leftarray-like (1-dimensional)
Left bounds for each interval.
- rightarray-like (1-dimensional)
Right bounds for each interval.
- closed{‘left’, ‘right’, ‘both’, ‘neither’}, default ‘right’
Whether the intervals are closed on the left-side, right-side, bothor neither.
- copybool, default False
Copy the data.
- dtypedtype, optional
If None, dtype will be inferred.
- Returns:
- IntervalArray
- Raises:
- ValueError
When a value is missing in only one ofleft orright.When a value inleft is greater than the corresponding valueinright.
See also
interval_rangeFunction to create a fixed frequency IntervalIndex.
IntervalArray.from_breaksConstruct an IntervalArray from an array of splits.
IntervalArray.from_tuplesConstruct an IntervalArray from an array-like of tuples.
Notes
Each element ofleft must be less than or equal to therightelement at the same position. If an element is missing, it must bemissing in bothleft andright. A TypeError is raised whenusing an unsupported type forleft orright. At the moment,‘category’, ‘object’, and ‘string’ subtypes are not supported.
Examples
>>>pd.arrays.IntervalArray.from_arrays([0,1,2],[1,2,3])<IntervalArray>[(0, 1], (1, 2], (2, 3]]Length: 3, dtype: interval[int64, right]