pandas.Index.intersection#

final Index.intersection(other, sort=False)[源代码]#

形成两个Index对象的交集。

这将返回一个新的索引,其中包含索引和 other

参数
other索引或类似数组
sortFALSE或NONE,默认为FALSE

是否对结果索引进行排序。

  • False:不对结果进行排序。

  • 无:对结果进行排序,但以下情况除外 selfother 值相等或无法比较值时。

退货
intersection索引

示例

>>> idx1 = pd.Index([1, 2, 3, 4])
>>> idx2 = pd.Index([3, 4, 5, 6])
>>> idx1.intersection(idx2)
Int64Index([3, 4], dtype='int64')