pyspark.pandas.Index.equals¶
-
Index.
equals
(other: pyspark.pandas.indexes.base.Index) → bool¶ Determine if two Index objects contain the same elements.
- Returns
- bool
True if “other” is an Index and it has the same elements as calling index; False otherwise.
Examples
>>> from pyspark.pandas.config import option_context >>> idx = ps.Index(['a', 'b', 'c']) >>> idx.name = "name" >>> midx = ps.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')]) >>> midx.names = ("nameA", "nameB")
For Index
>>> idx.equals(idx) True >>> with option_context('compute.ops_on_diff_frames', True): ... idx.equals(ps.Index(['a', 'b', 'c'])) True >>> with option_context('compute.ops_on_diff_frames', True): ... idx.equals(ps.Index(['b', 'b', 'a'])) False >>> idx.equals(midx) False
For MultiIndex
>>> midx.equals(midx) True >>> with option_context('compute.ops_on_diff_frames', True): ... midx.equals(ps.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')])) True >>> with option_context('compute.ops_on_diff_frames', True): ... midx.equals(ps.MultiIndex.from_tuples([('c', 'z'), ('b', 'y'), ('a', 'x')])) False >>> midx.equals(idx) False