I have dataframe with user data:
d = {'user_id': [9, 9, 9, 9, 9, 9, 26, 26, 26, 26],
'action_type': [1, 2, 7, 1, 1, 1, 1, 1, 1, 7],
'shift_status_id': [1, 1, 1, 1, 1, 1, 1, 1, 4, 1]}
df = pd.DataFrame(data=d)
The goal is to create a function which would count special values on basis of neighboring values for particular user, and than switch to next user. When I implement this:
for i in range(1,len(df)):
if df['user_id'][i]==df['user_id'][i-1]:
print("User is the same")
else:
print("User has changed!")
i=i+1
But when I do the same with full dataset (with more columns and rows, but it starts the same) I gen an error:
