pandas.Index.intersection#

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

形成两个 Index 对象的交集。

这将返回一个新索引,其中包含索引和 other 中共有的元素。

Parameters:
otherIndex 或类数组
sortTrue、False 或 None,默认为 False

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

  • None : 对结果进行排序,除非 selfother 相等或无法比较这些值。

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

  • True : 对结果进行排序(这可能会引发 TypeError)。

Returns:
pandas.DataFrame.keys

Examples

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