element of an array is the same as any of the previous elements pandas

The solution for “element of an array is the same as any of the previous elements pandas” can be found here. The following code will assist you in solving the problem.

df[‘match’] = df.col1.eq(df.col1.shift())
print (df)
col1 match
0 1 False
1 3 False
2 3 True
3 1 False
4 2 False
5 3 False
6 2 False
7 2 True

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in