 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 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
 