Skip to main content
`Ctrl`+`K`

# pandas.arrays.IntervalArray.to_tuples

IntervalArray.to_tuples(na_tuple=True)

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

  Parameters:
    na_tuple bool, default True

      If `True`, return `NA` as a tuple `(nan, nan)`. If `False`, just return `NA` as `nan`.

  Returns:
    ndarray or Index
      An ndarray of tuples representing the intervals

        if self is an IntervalArray.

      An Index of tuples representing the intervals

        if self is an IntervalIndex.

  See also

  `IntervalArray.to_list`

    Convert IntervalArray to a list of tuples.

  `IntervalArray.to_numpy`

    Convert IntervalArray to a numpy array.

  `IntervalArray.unique`

    Find unique intervals in an IntervalArray.

  Examples

  For `pandas.IntervalArray`:

      >>> idx = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 2)])
      >>> idx
      <IntervalArray>
      [(0, 1], (1, 2]]
      Length: 2, dtype: interval[int64, right]
      >>> idx.to_tuples()
      array([(np.int64(0), np.int64(1)), (np.int64(1), np.int64(2))],
            dtype=object)

  For `pandas.IntervalIndex`:

      >>> 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')