record[i,:] != 0这个能获取!=0的列下标吗,大家也偶人试了没,我这不行的
# 我改成了这样可以运行 for i in range(m): #获取一部电影评分用户的id ids = np.nonzero(record[i])[0] #ids = record[i,:] != 0 rating_mean[i] = np.mean(rating[i,ids]) #rating_norm[i,ids] -= rating_mean[i] rating_norm[i,ids] = rating[i,ids] - rating_mean[i] print("The row is {},mean rating is {},rating user size is {}" .format(i,rating_mean[i],ids.shape))