用法:
IntervalIndex.get_loc(key, method=None, tolerance=None)
獲取請求標簽的整數位置、切片或布爾掩碼。
- key:標簽
- method:{無,‘pad’/'fill',‘backfill’/'bfill',‘nearest’},可選
- 默認值:僅完全匹配。
- pad /ffill:如果沒有完全匹配,則查找 PREVIOUS 索引值。
- backfill /bfill:如果沒有完全匹配,則使用 NEXT 索引值。
- 最近:如果沒有完全匹配,則使用 NEAREST 索引值。通過首選較大的索引值來打破束縛距離。
- tolerance:int 或 float,可選
與不精確匹配的索引值的最大距離。匹配位置的索引值必須滿足等式
abs(index[loc] - key) <= tolerance
。
- int 或 slice 或 boolean 掩碼
- 如果結果是唯一的,則返回整數索引
- 如果 index 是單調的,則 loc 作為切片對象返回
- 否則,返回一個布爾掩碼
參數:
返回:
例子:
>>> unique_index = cudf.Index(list('abc')) >>> unique_index.get_loc('b') 1 >>> monotonic_index = cudf.Index(list('abbc')) >>> monotonic_index.get_loc('b') slice(1, 3, None) >>> non_monotonic_index = cudf.Index(list('abcb')) >>> non_monotonic_index.get_loc('b') array([False, True, False, True]) >>> numeric_unique_index = cudf.Index([1, 2, 3]) >>> numeric_unique_index.get_loc(3) 2
相關用法
- Python cudf.IntervalIndex.from_breaks用法及代碼示例
- Python cudf.Index.is_boolean用法及代碼示例
- Python cudf.Index.astype用法及代碼示例
- Python cudf.Index.set_names用法及代碼示例
- Python cudf.Index.is_numeric用法及代碼示例
- Python cudf.Index.sort_values用法及代碼示例
- Python cudf.Index.union用法及代碼示例
- Python cudf.Index.is_integer用法及代碼示例
- Python cudf.Index.join用法及代碼示例
- Python cudf.Index.get_level_values用法及代碼示例
- Python cudf.Index.isin用法及代碼示例
- Python cudf.Index.rename用法及代碼示例
- Python cudf.Index.to_pandas用法及代碼示例
- Python cudf.Index.difference用法及代碼示例
- Python cudf.Index.is_object用法及代碼示例
- Python cudf.Index.from_pandas用法及代碼示例
- Python cudf.Index.is_categorical用法及代碼示例
- Python cudf.Index.append用法及代碼示例
- Python cudf.Index.is_interval用法及代碼示例
- Python cudf.Index.intersection用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.IntervalIndex.get_loc。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。