How to return left endpoints of IntervalArray object as an index
Overview
The left attribute of an IntervalArray object is used to return the left endpoints intervals of the object as an index.
Note:
IntervalArrayis an object containing interval data such that the data is closed on the same side.
The left endpoint of an IntervalArray represents the start of the intervals of the object. For example, the intervals, (0, 2) and (3, 4), have their intervals starting from 0 and 3 respectively. Hence, they both represent the left endpoints of the intervals.
Syntax
IntervalArray.left
Syntax for the left attribute
Parameters
The left attribute doesn't take any parameters.
Return value
It returns the left endpoints of the IntervalArray object as an index.
Example
# A code to illustrate the left attribute of an IntervalArray object.# importing the pandas libraryimport pandas as pd# creating the IntervalArray objecta = pd.arrays.IntervalArray([pd.Interval(0, 4), pd.Interval(1, 5)])# obtaining the left endpointsprint(a.left)
Explanation
- Line 3: We import the
pandaslibrary. - Line 6: We create an
IntervalArrayobject,ausing thepd.arrays.IntervalArray()function. - Line 9: We use the
leftattribute to obtain the left endpoints ofa.