pandas.Series.duplicated

Posted zjuhaohaoxuexi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pandas.Series.duplicated相关的知识,希望对你有一定的参考价值。

Series.duplicated(selfkeep=‘first‘)

Indicate duplicate Series values.

Duplicated values are indicated as True values in the resulting Series. Either all duplicates, all except the first or all except the last occurrence of duplicates can be indicated.

Parameters:
keep {‘first’, ‘last’, False}, default ‘first’
  • ‘first’ : Mark duplicates as True except for the first occurrence.
  • ‘last’ : Mark duplicates as True except for the last occurrence.
  • False : Mark all duplicates as True.
Returns:
Series

Series indicating whether each value has occurred in the preceding values.

 

Examples:

By default, for each set of duplicated values, the first occurrence is set on False and all others on True:

>>> animals = pd.Series([‘lama‘, ‘cow‘, ‘lama‘, ‘beetle‘, ‘lama‘])
>>> animals.duplicated()
0    False
1    False
2     True
3    False
4     True
dtype: bool

which is equivalent to

 

>>> animals.duplicated(keep=‘first‘)
0    False
1    False
2     True
3    False
4     True
dtype: bool

  

 By using ‘last’, the last occurrence of each set of duplicated values is set on False and all others on True:
>>> animals.duplicated(keep=‘last‘)
0     True
1    False
2     True
3    False
4    False
dtype: bool

 

By setting keep on False, all duplicates are True:

 

 
>>> animals.duplicated(keep=False)
0     True
1    False
2     True
3    False
4     True
dtype: bool

  

 

  

以上是关于pandas.Series.duplicated的主要内容,如果未能解决你的问题,请参考以下文章

R留学生作业代码代写代编程代编程代编程

IPEX-1代/3代/4代/5代,PCB天线底座,公头,样式及封装尺寸图

JVM 年轻代 老年代 持久代 gc

深圳本地网店代运营公司

C线程代业代写代调试POSIX Threads代编码

jvm中的年轻代 老年代 持久代 gc