pandas列中的np.size和np.mean缺少值

时间:2019-10-15 15:51:25

标签: python pandas numpy data-science mean

我有一个包含电影收视率的数据集,我正在尝试获取每部电影的平均收视率和每部电影的收视率数量。我使用pandas agg函数汇总评级列并计算np.size和np.mean 但是,即使某些电影的评分至少为1,它仍会返回NaN值。我将删除所有只有一个等级的电影,但由于np.size返回了一些NaN值,所以我不知道要删除哪些电影

Image of the ratings dataframe

Image of the missing values after running the code below

movieProperties = ratings_df.groupby('movieId').agg({'rating': [np.size, np.mean]})

0 个答案:

没有答案