You are viewing documentation about an older version (1.21.0). View latest version

modin.pandas.Index.equals

Index.equals(other: Any) bool[source]

Determine if two Index objects are equal.

The things that are being compared are:

  • The elements inside the Index object.

  • The order of the elements inside the Index object.

Parameters:

other (Any) – The other object to compare against.

Returns:

True if “other” is an Index and it has the same elements and order as the calling index; False otherwise.

Return type:

bool

Examples

>>> idx1 = pd.Index([1, 2, 3])
>>> idx1
Index([1, 2, 3], dtype='int64')
>>> idx1.equals(pd.Index([1, 2, 3]))
True
Copy

The elements inside are compared

>>> idx2 = pd.Index(["1", "2", "3"])
>>> idx2
Index(['1', '2', '3'], dtype='object')
Copy
>>> idx1.equals(idx2)
True
Copy

The order is compared

>>> ascending_idx = pd.Index([1, 2, 3])
>>> ascending_idx
Index([1, 2, 3], dtype='int64')
>>> descending_idx = pd.Index([3, 2, 1])
>>> descending_idx
Index([3, 2, 1], dtype='int64')
>>> ascending_idx.equals(descending_idx)
False
Copy

The dtype is not compared

>>> int64_idx = pd.Index([1, 2, 3], dtype='int64')
>>> int64_idx
Index([1, 2, 3], dtype='int64')
Copy

# Snowpark pandas only supports signed integers so cast to uint won’t work >>> uint64_idx = pd.Index([1, 2, 3], dtype=’uint64’) >>> uint64_idx Index([1, 2, 3], dtype=’int64’) >>> int64_idx.equals(uint64_idx) True