pandas.IntervalIndex.to_tuples

IntervalIndex.to_tuples(na_tuple=True)[source]

Return an Index of tuples of the form (left, right)

Parameters:
na_tuple : boolean, default True

Returns NA as a tuple if True, (nan, nan), or just as the NA value itself if False, nan.

New in version 0.23.0.

Returns:
tuples: Index

Examples

>>> idx = pd.IntervalIndex.from_arrays([0, np.nan, 2], [1, np.nan, 3])
>>> idx.to_tuples()
Index([(0.0, 1.0), (nan, nan), (2.0, 3.0)], dtype='object')
>>> idx.to_tuples(na_tuple=False)
Index([(0.0, 1.0), nan, (2.0, 3.0)], dtype='object')    
Scroll To Top