gpt4 book ai didi

python - 属性错误: head not found when printing head() in Python

转载 作者:行者123 更新时间:2023-12-01 03:25:38 25 4
gpt4 key购买 nike

import sklearn

也许我不理解这里的一些基本内容,我只是不知道那可能是什么。我应该如何调试这个?

messages_tfidf = tfidf_transformer.transform(messages_bow)
print messages_tfidf

这部分工作正常,正如预期的那样。但是当我测试我对 .head() 的理解时遇到了麻烦

print messages_tfidf.head()

输出错误

AttributeError Traceback (most recent call last) 1 messages_tfidf = tfidf_transformer.transform(messages_bow) 2 print messages_tfidf ----> 3 print messages_tfidf.head()

AttributeError: head not found

有人可以帮助我理解我的逻辑差距吗?

最佳答案

Head 是 pandas DataFrame 的一个函数。

你可以这样做:

import pandas as pd

dframe = pd.DataFrame(messages_tfidf)
dframe.head()

关于python - 属性错误: head not found when printing head() in Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41416320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com