title: An efficient way to calculate the mean of each column or row of non-zero elements
body: <p>I have a numpy array for ratings given by users on movies. The rating is between 1 and 5, while 0 means that a user does not rate on a movie. I want to calculate the average rating of each movie, and the average rating of each user. In other words, I will calculate the mean of each column or row of non-zero elements.</p>
  
  <p>Is there an efficient numpy array function to handle this case? I know manually iterating ratings by columns or rows can solve the problem.</p>
  
  <p>Thanks in advance!</p>