- 用法:- Index.duplicated(keep='first')
- 指示重複的索引值。 - 重複值在結果數組中表示為 - True值。可以指示所有重複,除了第一個之外的所有重複,或者除了最後一次出現的重複之外的所有重複。- keep:{‘first’, ‘last’, False},默認 ‘first’
- 一組重複項中要標記為缺失的值。 - ‘first’:將重複項標記為 - True,但第一次出現除外。
- ‘last’:將重複項標記為 - True,最後一次出現除外。
- False:將所有重複項標記為- True。
 
 
- np.ndarray[bool]
 
 - 參數:- 返回:- 例子:- 默認情況下,對於每組重複值,第一次出現設置為 False,其他所有設置為 True: - >>> idx = pd.Index(['lama', 'cow', 'lama', 'beetle', 'lama']) >>> idx.duplicated() array([False, False, True, False, True])- 這相當於 - >>> idx.duplicated(keep='first') array([False, False, True, False, True])- 通過使用‘last’,每組重複值的最後一次出現設置為 False,所有其他值設置為 True: - >>> idx.duplicated(keep='last') array([ True, False, True, False, False])- 通過設置 keep on - False,所有重複項都是 True:- >>> idx.duplicated(keep=False) array([ True, False, True, False, True])
相關用法
- Python pandas.Index.drop_duplicates用法及代碼示例
- Python pandas.Index.droplevel用法及代碼示例
- Python pandas.Index.difference用法及代碼示例
- Python pandas.Index.delete用法及代碼示例
- Python pandas.Index.value_counts用法及代碼示例
- Python pandas.Index.argmin用法及代碼示例
- Python pandas.Index.is_categorical用法及代碼示例
- Python pandas.Index.to_series用法及代碼示例
- Python pandas.Index.str用法及代碼示例
- Python pandas.Index.to_numpy用法及代碼示例
- Python pandas.Index.is_object用法及代碼示例
- Python pandas.Index.slice_indexer用法及代碼示例
- Python pandas.Index.is_interval用法及代碼示例
- Python pandas.Index.notnull用法及代碼示例
- Python pandas.Index.equals用法及代碼示例
- Python pandas.Index.set_names用法及代碼示例
- Python pandas.Index.searchsorted用法及代碼示例
- Python pandas.Index.is_monotonic_increasing用法及代碼示例
- Python pandas.Index.min用法及代碼示例
- Python pandas.Index.is_monotonic_decreasing用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Index.duplicated。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
