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 - Check if the IntervalIndex has overlapping intervals
To check if the IntervalIndex has overlapping intervals, use the Intervalndex.is_overlapping property. At first, import the required libraries −
import pandas as pd
Create IntervalIndex −
interval = pd.IntervalIndex.from_tuples([(10, 20), (15, 25)])
Display the interval −
print("IntervalIndex...\n",interval)
Check if the interval is overlapping or not −
print("\nIs the interval overlapping?\n",interval.is_overlapping)
Example
Following is the code −
import pandas as pd
# Create IntervalIndex
interval = pd.IntervalIndex.from_tuples([(10, 20), (15, 25)])
# Display the interval
print("IntervalIndex...\n",interval)
# Display the interval length
print("\nIntervalIndex length...\n",interval.length)
# Check if the interval is overlapping or not
print("\nIs the interval overlapping?\n",interval.is_overlapping)
Output
This will produce the following output −
IntervalIndex... IntervalIndex([(10, 20], (15, 25]], dtype='interval[int64, right]') IntervalIndex length... Int64Index([10, 10], dtype='int64') Is the interval overlapping? True
Advertisements
