
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Pandas - Determine if two Index objects with opposite orders are equal or not
To determine if two Index objects with opposite orders are equal or not, use the equals() method.
At first, import the required libraries −
import pandas as pd
Creating Pandas index1 and index2 −
index1 = pd.Index([15, 25, 35, 45, 55, 65, 75, 85, 95]) index2 = pd.Index([95, 85, 75, 65, 55, 45, 35, 25, 15])
Display the index1 and index2 −
print("Pandas Index1...\n",index1) print("Pandas Index2...\n",index2)
Check whether two index objects with opposite order equal or not −
print("\nAre two Index objects with opposite order equal?" "\n",index1.equals(index2))
Example
Following is the code −
import pandas as pd # Creating Pandas index1 and index2 index1 = pd.Index([15, 25, 35, 45, 55, 65, 75, 85, 95]) index2 = pd.Index([95, 85, 75, 65, 55, 45, 35, 25, 15]) # Display the index1 and index2 print("Pandas Index1...\n",index1) print("Pandas Index2...\n",index2) print("\nAre two Index objects with opposite order equal?" "\n",index1.equals(index2))
Output
This will produce the following code −
Pandas Index1... Int64Index([15, 25, 35, 45, 55, 65, 75, 85, 95], dtype='int64') Pandas Index2... Int64Index([95, 85, 75, 65, 55, 45, 35, 25, 15], dtype='int64') Are two Index objects with opposite order equal? False
- Related Articles
- Python Pandas - Determine if two Index objects are equal
- Python Pandas - Check if the dataframe objects are equal or not
- Check if two StringDictionary objects are equal or not in C#
- Python Pandas – Check if any specific column of two DataFrames are equal or not
- Python Pandas - Determine if two CategoricalIndex objects contain the same elements
- Python Pandas - Check if the Pandas Index holds Interval objects
- Python Pandas - Form the Union of two Index objects with different datatypes
- Python Pandas - Form the intersection of two Index objects
- Python Pandas - Form the Union of two Index objects
- Python Pandas - Form the Union of two Index objects but do not sort the result
- Check if two strings are equal or not in Arduino
- Python Pandas - Compute the symmetric difference of two Index objects
- Python Pandas - Return if the index is monotonic increasing (only equal or increasing) values
- Python Pandas - Return if the index is monotonic decreasing (only equal or decreasing) values
- Golang Program to Check If Two Arrays are Equal or Not

Advertisements