如何解决Python TypeError:类型不了解
我正在创建一个推荐系统,当我运行此代码时,我会遇到一个错误:
from scipy.sparse.linalg import svds
# Singular Value Decomposition
U, sigma, Vt = svds(pivot_df, k = 10)
并且我遇到了此错误:“ TypeError:type不理解”。
造成此错误的原因是什么?我应该如何解决?
I am creating a recommendation system and when I run this code I'm getting an error:
from scipy.sparse.linalg import svds
# Singular Value Decomposition
U, sigma, Vt = svds(pivot_df, k = 10)
And I'm getting this error: "TypeError: type not understood".
What could be the reason for this error and how should I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
svds()以稀疏矩阵或ndarray作为输入。
但是您通过的是数据框架。使用以下命令检查类型。
因此,您需要将数据框架转换为np.ndarray,同时将其传递到 svds()。
svds() takes a sparse matrix or an ndarray as input.
But what you are passing is a Dataframe. Check the type by using the below command.
Hence, you need to convert the Dataframe to np.ndarray while passing it to svds().