當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python cudf.Index.difference用法及代碼示例

用法:

Index.difference(other, sort=None)

返回一個新索引,其中包含索引中不在 other 中的元素。

這是兩個 Index 對象的集合差。

參數

other索引或array-like
sort假或無,默認無

是否對結果索引進行排序。默認情況下,嘗試對值進行排序,但任何來自不可比較元素的 TypeError 都會被 cudf 捕獲。

  • 無:嘗試對結果進行排序,但從比較不可比較的元素中捕獲任何類型錯誤。
  • False:不對結果進行排序。

返回

difference index

例子

>>> import cudf
>>> idx1 = cudf.Index([2, 1, 3, 4])
>>> idx1
Int64Index([2, 1, 3, 4], dtype='int64')
>>> idx2 = cudf.Index([3, 4, 5, 6])
>>> idx2
Int64Index([3, 4, 5, 6], dtype='int64')
>>> idx1.difference(idx2)
Int64Index([1, 2], dtype='int64')
>>> idx1.difference(idx2, sort=False)
Int64Index([2, 1], dtype='int64')

相關用法


注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Index.difference。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。