
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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
- Related Articles
- Python Pandas IntervalIndex - Check if Intervals that share closed endpoints overlap
- Python Pandas - Check elementwise if the Intervals in the IntervalIndex contain the value
- Check elementwise if the Intervals in the IntervalIndex contain the value in Python Pandas
- Python Pandas IntervalIndex - Check if Intervals that only have an open endpoint in common overlap or not
- Python Pandas - Check elementwise if the Intervals contain the value
- Python Pandas - Check whether the IntervalIndex intervals are closed on the left-side, right-side, both or neither
- Python Pandas - Check if the Intervals in the IntervalArray is empty
- Python Pandas IntervalIndex - Get the locations of all the relevant interval if a label is in several intervals
- Python Pandas - Check if the index has NaNs
- Python Pandas - Check if the index has unique values
- Python Pandas - Check if the index has duplicate values
- Python Pandas IntervalIndex - Check if an interval that contains points is empty or not
- Python Pandas IntervalIndex - Check if an interval with missing values is empty or not
- Python Pandas - Create an IntervalIndex
- Python Pandas - Get the midpoint from the IntervalIndex

Advertisements