当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python pyspark Index.identical用法及代码示例


本文简要介绍 pyspark.pandas.Index.identical 的用法。

用法:

Index.identical(other: pyspark.pandas.indexes.base.Index) → bool

与 equals 类似,但检查其他可比较的属性是否也相等。

返回

bool

如果两个 Index 对象具有相同的元素和相同的类型,则为 True,否则为 False。

例子

>>> from pyspark.pandas.config import option_context
>>> idx = ps.Index(['a', 'b', 'c'])
>>> midx = ps.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')])

对于索引

>>> idx.identical(idx)
True
>>> with option_context('compute.ops_on_diff_frames', True):
...     idx.identical(ps.Index(['a', 'b', 'c']))
True
>>> with option_context('compute.ops_on_diff_frames', True):
...     idx.identical(ps.Index(['b', 'b', 'a']))
False
>>> idx.identical(midx)
False

对于MultiIndex

>>> midx.identical(midx)
True
>>> with option_context('compute.ops_on_diff_frames', True):
...     midx.identical(ps.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')]))
True
>>> with option_context('compute.ops_on_diff_frames', True):
...     midx.identical(ps.MultiIndex.from_tuples([('c', 'z'), ('b', 'y'), ('a', 'x')]))
False
>>> midx.identical(idx)
False

相关用法


注:本文由纯净天空筛选整理自spark.apache.org大神的英文原创作品 pyspark.pandas.Index.identical。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。