使用Python查找两个Elasticsearch索引的差集
使用Python查找两个Elasticsearch索引的差集 \u003cbr\u003e \u003cbr\u003e 要通过Python查询两个索引的差集,可以使用difference()方法。下面是一个例子: \u003cbr\u003e \u003cbr\u003e python \u003cbr\u003e import pandas as pd \u003cbr\u003e \u003cbr\u003e # 创建两个索引 \u003cbr\u003e index1 = pd.Index(['A', 'B', 'C', 'D']) \u003cbr\u003e index2 = pd.Index(['B', 'C', 'D', 'E']) \u003cbr\u003e \u003cbr\u003e # 计算差集 \u003cbr\u003e difference = index1.difference(index2) \u003cbr\u003e \u003cbr\u003e print(difference) \u003cbr\u003e \u003cbr\u003e 输出结果为: \u003cbr\u003e \u003cbr\u003e \u003cbr\u003e Index(['A'], dtype='object') \u003cbr\u003e \u003cbr\u003e \u003cbr\u003e 在上述例子中,difference()方法从index1中计算了不在index2中的元素,即差集。差集的结果是一个新的索引对象。
原文地址: https://www.cveoy.top/t/topic/pL77 著作权归作者所有。请勿转载和采集!