- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Pandas - Check if an interval is empty if closed from the both sides
To check if an interval is empty if closed from both sides, use the interval.is_empty property. At first, import the required libraries −
import pandas as pd
Interval closed from the both sides. Interval set using the "closed" parameter with value "both"
interval = pd.Interval(0, 0, closed='both')
Display the interval
print("Interval...\n",interval)
Check whether interval is empty when it is closed from both sides. An Interval that contains a single point is not empty i.e. False is returned
print("\nIs Interval empty? \n",interval.is_empty)
Example
Following is the code
import pandas as pd # interval closed from the both sides # Interval set using the "closed" parameter with value "both" interval = pd.Interval(0, 0, closed='both') # display the interval print("Interval...\n",interval) # display the interval length print("\nInterval length...\n",interval.length) # check whether interval is empty when it is closed from both sides # An Interval that contains a single point is not empty i.e. False is returned print("\nIs Interval empty? \n",interval.is_empty)
Output
This will produce the following code
Interval... [0, 0] Interval length... 0 Is Interval empty? False
- Related Articles
- Python Pandas - Check if an interval is empty if closed from the left side
- Python Pandas - Check if an interval is empty
- 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 an interval set as open is empty
- 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 whether the interval is closed on the left-side, right-side, both or neither
- Python Pandas - Create a closed time interval and check for existence of both the endpoints
- 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

Advertisements