pandas.IntervalIndex.from_arrays
-
classmethod IntervalIndex.from_arrays(left, right, closed='right', name=None, copy=False, dtype=None)[source] -
Construct from two arrays defining the left and right bounds.
Parameters: -
left : array-like (1-dimensional) -
Left bounds for each interval.
-
right : array-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, both or neither.
-
copy : boolean, default False -
Copy the data.
-
dtype : dtype, optional -
If None, dtype will be inferred.
New in version 0.23.0.
Returns: - IntervalIndex
Raises: - ValueError
-
When a value is missing in only one of
leftorright. When a value inleftis greater than the corresponding value inright.
See also
-
interval_range - Function to create a fixed frequency IntervalIndex.
-
IntervalIndex.from_breaks - Construct an IntervalIndex from an array of splits.
-
IntervalIndex.from_tuples - Construct an IntervalIndex from an array-like of tuples.
Notes
Each element of
leftmust be less than or equal to therightelement at the same position. If an element is missing, it must be missing in bothleftandright. A TypeError is raised when using an unsupported type forleftorright. At the moment, ‘category’, ‘object’, and ‘string’ subtypes are not supported.Examples
>>> IntervalIndex.from_arrays([0, 1, 2], [1, 2, 3]) IntervalIndex([(0, 1], (1, 2], (2, 3]], closed='right', dtype='interval[int64]') -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.IntervalIndex.from_arrays.html