Question: I have a `dataframe` in which first column is :

```
id = ["6LDFTLL9", "6LDFTLL9", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE","6VPZ4T5P", "EHYXE34N", "EHYXE34N", "TT56GTN2","TT56GTN2" ]

```

I want to check if the consecutive id are same or not. I tried with the following code but it didn't work.

```
i=1
for index, row in df.iterrows():
     df.id.iloc[i] == df.id.iloc[i + 1]:
     i = i+1

```

Answer: 
```
df = pd.DataFrame({'id':["6LDFTLL9", "6LDFTLL9", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE","6VPZ4T5P", "EHYXE34N", "EHYXE34N", "TT56GTN2","TT56GTN2" ]})

df['Consec_id'] = df['id'] == df.shift()['id']

print(df)

```

Output:

```
          id Consec_id
0   6LDFTLL9     False
1   6LDFTLL9      True
2   7SKDEZWE     False
3   7SKDEZWE      True
4   7SKDEZWE      True
5   7SKDEZWE      True
6   6VPZ4T5P     False
7   EHYXE34N     False
8   EHYXE34N      True
9   TT56GTN2     False
10  TT56GTN2      True

```

Count duplicates:

```
df['Consec_id'].sum()

```

Output

```
6

```
By using this data frame : 

```
df = pd.DataFrame({'id':["6LDFTLL9", "6LDFTLL9", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE", "7SKDEZWE","6VPZ4T5P", "EHYXE34N", "EHYXE34N", "TT56GTN2","TT56GTN2" ]})

```

Generating a new column : 

```
df['id_2'] = df.id.shift(-1)
df.dropna(inplace= True)

```

now you can compare if two consecutive values are the same by using a simple filter :

```
df[df['id'] == df[id_2]]

```

and you will get the desired result : 

```
        id        id_2
0   6LDFTLL9    6LDFTLL9
2   7SKDEZWE    7SKDEZWE
3   7SKDEZWE    7SKDEZWE
4   7SKDEZWE    7SKDEZWE
7   EHYXE34N    EHYXE34N
9   TT56GTN2    TT56GTN2

```