【发布时间】:2023-03-24 05:26:01
【问题描述】:
由于我正在创建一个数据框,我不明白为什么会出现数组错误。
M2 = df.groupby(['song_id', 'user_id']).rating.mean().unstack()
M2 = np.maximum(-1, (M - 3).fillna(0) / 2.) # scale to -1..+1 (treat "0" scores as "1" scores)
M2.head(2)
AttributeError: 'numpy.ndarray' object has no attribute 'fillna'
【问题讨论】:
-
M定义为什么?
标签: python pandas dataframe attributeerror