- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 the index is empty with 0 elements
To check if the index is empty with 0 elements, use the index.empty property in Pandas.
At first, import the required libraries −
import pandas as pd
Creating the index −
index = pd.Index([])
Display the index −
print("Pandas Index...\n",index)
Check for empty index −
print("\nIs the index empty?\n",index.empty)
Example
Following is the code −
import pandas as pd # Creating the index index = pd.Index([]) # Display the index print("Pandas Index...\n",index) # Return the number of elements in the Index print("\nNumber of elements in the index...\n",index.size) # check for empty index print("\nIs the index empty?\n",index.empty)
Output
This will produce the following code −
Pandas Index... Index([], dtype='object') Number of elements in the index... 0 Is the index empty? True
Advertisements
To Continue Learning Please Login
Login with Google