Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.IntervalIndex#

classpandas.IntervalIndex(data,closed=None,dtype=None,copy=False,name=None,verify_integrity=True)[source]#

Immutable index of intervals that are closed on the same side.

Parameters:
dataarray-like (1-dimensional)

Array-like (ndarray,DateTimeArray,TimeDeltaArray) containingInterval objects from which to build the IntervalIndex.

closed{‘left’, ‘right’, ‘both’, ‘neither’}, default ‘right’

Whether the intervals are closed on the left-side, right-side, both orneither.

dtypedtype or None, default None

If None, dtype will be inferred.

copybool, default False

Copy the input data.

nameobject, optional

Name to be stored in the index.

verify_integritybool, default True

Verify that the IntervalIndex is valid.

Attributes

closed

String describing the inclusive side the intervals.

is_empty

Indicates if an interval is empty, meaning it contains no points.

is_non_overlapping_monotonic

Return a boolean whether the IntervalArray is non-overlapping and monotonic.

is_overlapping

Return True if the IntervalIndex has overlapping intervals, else False.

values

Return an array representing the data in the Index.

left

right

mid

length

Methods

from_arrays(left, right[, closed, name, ...])

Construct from two arrays defining the left and right bounds.

from_tuples(data[, closed, name, copy, dtype])

Construct an IntervalIndex from an array-like of tuples.

from_breaks(breaks[, closed, name, copy, dtype])

Construct an IntervalIndex from an array of splits.

contains(*args, **kwargs)

Check elementwise if the Intervals contain the value.

overlaps(*args, **kwargs)

Check elementwise if an Interval overlaps the values in the IntervalArray.

set_closed(*args, **kwargs)

Return an identical IntervalArray closed on the specified side.

to_tuples(*args, **kwargs)

Return an ndarray (if self is IntervalArray) or Index (if self is IntervalIndex) of tuples of the form (left, right).

See also

Index

The base pandas Index type.

Interval

A bounded slice-like interval; the elements of an IntervalIndex.

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 theuser guidefor more.

Examples

A newIntervalIndex is typically constructed usinginterval_range():

>>>pd.interval_range(start=0,end=5)IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],              dtype='interval[int64, right]')

It may also be constructed using one of the constructormethods:IntervalIndex.from_arrays(),IntervalIndex.from_breaks(), andIntervalIndex.from_tuples().

See further examples in the doc strings ofinterval_range and thementioned constructor methods.


[8]ページ先頭

©2009-2025 Movatter.jp