I want to calculate the mean ratings for each user using his specified ratings.
I built a ratings matrix from my ratings dataframe as follow:
ratings_pivot = filter_ratings.pivot('User_id','item_id','Rating').fillna(0).astype(int).values
But then didn't know how to consider only nonzero values when calculating. The method mean() provided by numpy, if used on axis = 1 it will consider all elements values even those equal to zero.
How to do it?