pandas.IntervalIndex.to_tuples#
- IntervalIndex.to_tuples(na_tuple=True)[source]#
Return an Index of tuples of the form (left, right).
This method extracts the bounds of each interval as a tuple, useful for iteration or conversion to other data structures.
- Parameters:
- na_tuplebool, default True
If
True, returnNAas a tuple(nan, nan). IfFalse, just returnNAasnan.
- Returns:
- Index
An Index of tuples representing the intervals.
See also
arrays.IntervalArray.to_tuplesAnalogous method for IntervalArray.
Examples
>>> idx = pd.interval_range(start=0, end=2) >>> idx IntervalIndex([(0, 1], (1, 2]], dtype='interval[int64, right]') >>> idx.to_tuples() Index([(0, 1), (1, 2)], dtype='object')