Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Python Pandas - Check if the index has unique values
To check if the index has unique values, use the index.is_unique.
At first, import the required libraries −
import pandas as pd
Let us create the index −
index = pd.Index([50, 40, 30, 20, 10])
Display the index −
print("Pandas Index...\n",index)
Check if the index is having unique values −
print("\nIs the Pandas index having unique values?\n",index.is_unique)
Example
Following is the code −
import pandas as pd
# Creating the index
index = pd.Index([50, 40, 30, 20, 10])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Check if the index is having unique values
print("\nIs the Pandas index having unique values?\n",index.is_unique)
Output
This will produce the following code −
Pandas Index... Int64Index([50, 40, 30, 20, 10], dtype='int64') Array... [50 40 30 20 10] Is the Pandas index having unique values? True
Advertisements
