I was stuck with this and the issue was after converting the user id’s from to to n-1, I was writing to a different variable and was using the same older one
In my case problem was that I coded categorical features in test set in other way that I did it in train set. In other words I did this:
for v in cat_cols: train_df[v] = train_df[v].astype('category').cat.as_ordered()
for v in cat_cols: test_df[v] = test_df[v].astype('category').cat.as_ordered()
and it was the mistake. The solution was to code to categorical just train set and after this did apply_cats() function
for v in cat_cols: train_df[v] = train_df[v].astype('category').cat.as_ordered()
apply_cats(test_df, train_df)