
- 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 an interval is empty
To check if an Interval is empty, use the interval.is_empty property. At first, import the required libraries −
import pandas as pd
Create an interval
interval = pd.Interval(0, 0, closed='right')
Display the interval
print("Interval...\n",interval)
Check whether interval is empty
print("\nIs Interval empty? \n",interval.is_empty)
Example
Following is the code
import pandas as pd # Create an interval interval = pd.Interval(0, 0, closed='right') # display the interval print("Interval...\n",interval) # display the interval length print("\nInterval length...\n",interval.length) # check whether interval is empty print("\nIs Interval empty? \n",interval.is_empty)
Output
This will produce the following code
Interval... (0, 0] Interval length... 0 Is Interval empty? True
- Related Articles
- Python Pandas - Check if an interval set as open is empty
- Python Pandas - Check if an interval is empty if closed from the left side
- Python Pandas - Check if an interval is empty if closed from the both sides
- 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 IntervalIndex - Indicates if an interval is empty (contains no points)
- Python Pandas - Check if an element belongs to an Interval
- Python Pandas - Check if an Interval is closed on the left side
- Python Pandas - Check if an Interval is closed on the right side
- Python Pandas - Check if the Pandas Index holds Interval objects
- Python Pandas - Check if the Intervals in the IntervalArray is empty
- Python Pandas - Check if the index is empty with 0 elements
- Python Pandas - Check if the interval is open on the left side
- Python Pandas - Check if the interval is open on the right side
- Check elementwise if an Interval overlaps the values in the IntervalArray in Python Pandas

Advertisements