I have the following PySpark dataframe.
| ID |
|---|
| 7773 |
| 7773 |
| 7372 |
| 7372 |
| 2032 |
| 2032 |
| 2032 |
I need to compare the first row value with the next row value. If I was doing this in pandas I would be using the following logic:
for i in range(df.shape[0]-1):
if df.iloc[i]['ID'] == df.iloc[i+1]['ID']:
print(True)
else:
print(False)
How can I do the same in PySpark dataframe or SQL?