【发布时间】:2019-07-30 05:48:24
【问题描述】:
我有一个图书评级数据集(用户 ID、isbn、电影标题、评级……),我想回答一个问题“如果我喜欢这本书,我可能还会考虑这些……” .
我试图从我的数据集中创建一个数据透视表,但由于未堆叠的数据框太大而导致溢出错误,所以我只是对其进行了分组并尝试使用 corrwith() 如下:
#data_p = pd.pivot_table(data, values='Book-Rating', index='User-ID', columns='ISBN') #This raises an overflow error
data_p = data.groupby(['User-ID', 'Book-Title'])['Book-Rating'].mean().to_frame()
i = int(data.index[data['Book-Title'] == 'The Fellowship of the Ring (The Lord of the Rings, Part 1)'][0])
data_p.corrwith(i)
...引发
AttributeError: 'int' 对象没有属性 '_get_numeric_data'
我也试过了:
data_p.corrwith('The Fellowship of the Ring (The Lord of the Rings, Part 1)')
这会给出与“字符串”对象相同的错误。
我们将不胜感激。
【问题讨论】:
-
corrwith 期望另一个数据帧或系列作为参数,但您传入字符串
标签: python