pandas.arrays.IntervalArray — pandas 3.0.0.dev0+2103.g41968a550a documentation (original) (raw)
class pandas.arrays.IntervalArray(data, closed=None, dtype=None, copy=False, verify_integrity=True)[source]#
Pandas array for interval data that are closed on the same side.
Parameters:
dataarray-like (1-dimensional)
Array-like (ndarray, DateTimeArray
, TimeDeltaArray
) containing Interval objects from which to build the IntervalArray.
closed{‘left’, ‘right’, ‘both’, ‘neither’}, default ‘right’
Whether the intervals are closed on the left-side, right-side, both or neither.
dtypedtype or None, default None
If None, dtype will be inferred.
copybool, default False
Copy the input data.
verify_integritybool, default True
Verify that the IntervalArray is valid.
Attributes
Methods
See also
Index
The base pandas Index type.
Interval
A bounded slice-like interval; the elements of an IntervalArray.
interval_range
Function to create a fixed frequency IntervalIndex.
cut
Bin values into discrete Intervals.
qcut
Bin values into equal-sized Intervals based on rank or sample quantiles.
Notes
See the user guidefor more.
Examples
A new IntervalArray
can be constructed directly from an array-like ofInterval
objects:
pd.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)]) [(0, 1], (1, 5]] Length: 2, dtype: interval[int64, right]
It may also be constructed using one of the constructor methods: IntervalArray.from_arrays(),IntervalArray.from_breaks(), and IntervalArray.from_tuples().