

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 - Show which entries in a Pandas Index are not NA
To show which entries in a Pandas Index are not NA, use the index.notna() method. At first, import the required libraries -
import pandas as pd import numpy as np
Creating Pandas index with some NaN values −
index = pd.Index([5, 65, np.nan, 17, 75, np.nan])
Display the Pandas index −
print("Pandas Index...\n",index)
Show which entries in a Pandas index are not-NA. Return True for non-NA entries −
print("\nCheck which entries are not-NA...\n", index.notna())
Example
Following is the code −
import pandas as pd import numpy as np # Creating Pandas index with some NaN values index = pd.Index([5, 65, np.nan, 17, 75, np.nan]) # Display the Pandas index print("Pandas Index...\n",index) # Return the number of elements in the Index print("\nNumber of elements in the index...\n",index.size) # Return the dtype of the data print("\nThe dtype object...\n",index.dtype) # Show which entries in a Pandas index are not-NA # Return True for non-NA entries print("\nCheck which entries are not-NA...\n", index.notna())
Output
This will produce the following output −
Pandas Index... Float64Index([5.0, 65.0, nan, 17.0, 75.0, nan], dtype='float64') Number of elements in the index... 6 The dtype object... float64 Check which entries are not-NA... [ True True False True True False]
- Related Questions & Answers
- Python - Show which entries in a Pandas Index are NA
- Python Pandas - Determine if two Index objects with opposite orders are equal or not
- What does immutable mean? Which Python types are mutable and which are not?
- Python Pandas - Return a new Index with elements of index not in other and get the difference
- Python Pandas - Return a new Index with elements of index not in other but unsort the result
- Python Pandas - Return an Index with entries denoting the length of each Interval in the IntervalArray
- Python Pandas - Determine if two Index objects are equal
- Difference between SHOW INDEX, SHOW INDEXES and SHOW KEYS in MySQL?
- Python Pandas - Alter index name
- Python Pandas - Return whether all elements in the index are True
- Python Pandas - Drop the value when all levels are NaN in a Multi-index
- What happens if the specified index is not present in the series Python Pandas?
- Python Pandas - Create a DataFrame from original index but enforce a new index
- Python Pandas - Indicate duplicate index values
- Program to count index pairs for which array elements are same in Python
Advertisements