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: 
Given this dataframe

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

df[df.id == df.id.shift(1)]

```

will return the ids which are the same as previous ids.

```
    id
1   6LDFTLL9
3   7SKDEZWE
4   7SKDEZWE
5   7SKDEZWE
8   EHYXE34N
10  TT56GTN2

```

If you are looking for identical pairs, more suitable thing to do would be

```
df.loc[(df.id == df.id.shift(1))|(df.id == df.id.shift(-1))]

```

This will provide same ids in the sets of two from where on you can proceed to do further calculations.

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

```

Note that in this case it only removes the id at index 6 as it doesn't have a matching pair above or below it.

Hope this helps.
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

```