Sarah Mestiri

I tried your code on my side and it is working fine with no errors but I am using python 3.6. I think that the issue is coming from differences in the way python2 and python3 handles string. Check the this article for more info. You need to find a way to change the encoding of the pandas dataframe from unicode to str for it to work with python 2. I didn’t try it on my side by can you try adding the below before loading the dataframe into surprise

df['User-ID'] = df['User-ID'].astype(str)

Can you please try it and let me know if it works?

More info:

The issue occurs in the below line of code in surprise

iiid = 'UKN__' + str(iid)

str(iid) is handled differently between python 2 and 3.

Like what you read? Give Maher Malaeb a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.