Hey, thanks again for helping for so long! My formula gives class value of 1 or 2 because that was code provided by the lecturer, but if you look at the code I have a line were I change it to 0 or 1:
df_raw['Preference Group'] = df_raw['Preference Group'] - 1

the 0 or 2 is a typo in my comment, sorry for that