Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Python Pandas - Get the left bound for the IntervalIndex
To get the left bound for the IntervalIndex, use the interval.left property in Pandas. At first, import the required libraries −
import pandas as pd
Create IntervalIndex −
interval = pd.IntervalIndex.from_arrays([5, 10, 15], [15, 20, 25])
Display the interval −
print("IntervalIndex...\n",interval)
Get the left bound −
print("\nThe left bound for the IntervalIndex...\n",interval.left)
Example
Following is the code −
import pandas as pd
# Create IntervalIndex
interval = pd.IntervalIndex.from_arrays([5, 10, 15], [15, 20, 25])
# Display the interval
print("IntervalIndex...\n",interval)
# Display the interval length
print("\nIntervalIndex length...\n",interval.length)
# Check whether the IntervalIndex is closed on the left-side, right-side, both or neither
print("\nChecking for the type of IntervalIndex...\n",interval.closed)
# Get the left bound
print("\nThe left bound for the IntervalIndex...\n",interval.left)
Output
This will produce the following output −
IntervalIndex... IntervalIndex([(5, 15], (10, 20], (15, 25]], dtype='interval[int64, right]') IntervalIndex length... Int64Index([10, 10, 10], dtype='int64') Checking for the type of IntervalIndex... right The left bound for the IntervalIndex... Int64Index([5, 10, 15], dtype='int64')
Advertisements
