Mars.dataframe.Series.duplicated#
- Series.duplicated(keep='first', method='auto')#
指示重复的系列值。
重复的值在结果序列中表示为
True值。可以指示所有重复项、除第一个外的所有项或除最后一个外的所有重复项。- Parameters
keep ({'first', 'last', False}, default 'first') –
处理去重的方法:
’first’ : 除第一个出现外,将重复项标记为
True。’last’ : 除最后一个出现外,将重复项标记为
True。False: 将所有重复项标记为True。
- Returns
系列指示每个值是否出现在之前的值中。
- Return type
另请参阅
Index.duplicated与pandas.Index的等效方法。
DataFrame.duplicated相当于pandas.DataFrame上的方法。
Series.drop_duplicates从序列中移除重复值。
示例
默认情况下,对于每组重复的值,第一个出现的值设置为 False,而所有其他值设置为 True:
>>> import mars.dataframe as md
>>> animals = md.Series(['lame', 'cow', 'lame', 'beetle', 'lame']) >>> animals.duplicated().execute() 0 False 1 False 2 True 3 False 4 True dtype: bool
这相当于
>>> animals.duplicated(keep='first').execute() 0 False 1 False 2 True 3 False 4 True dtype: bool
通过使用“last”,每组重复值的最后一次出现被设置为 False,所有其他的被设置为 True:
>>> animals.duplicated(keep='last').execute() 0 True 1 False 2 True 3 False 4 False dtype: bool
通过将 keep 设置为
False,所有重复项都是 True:>>> animals.duplicated(keep=False).execute() 0 True 1 False 2 True 3 False 4 True dtype: bool