Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用wordcloud错误运行代码_Python_Python 3.x_Word Cloud_Wordcloud2 - Fatal编程技术网

Python 如何使用wordcloud错误运行代码

Python 如何使用wordcloud错误运行代码,python,python-3.x,word-cloud,wordcloud2,Python,Python 3.x,Word Cloud,Wordcloud2,我试图从Python中的数据帧中创建wordcloud,但是当我试图运行代码时,它会给我一条错误消息,如下所示:NameError:name'text'未定义。 dataframe由从本地报纸上搜集的数据组成,我想做的是用最常提到的单词制作一个wordcloud 数据帧如下所示: 代码的“文本”未定义。 这样试试 text = '' for i in range(len(df)): text += df.iloc[i,2] 或 该错误意味着您试图使用.generate(text),

我试图从Python中的数据帧中创建wordcloud,但是当我试图运行代码时,它会给我一条错误消息,如下所示:NameError:name'text'未定义。 dataframe由从本地报纸上搜集的数据组成,我想做的是用最常提到的单词制作一个wordcloud

数据帧如下所示:


代码的“文本”未定义。 这样试试

text = ''

for i in range(len(df)):
    text += df.iloc[i,2]


该错误意味着您试图使用
.generate(text)
,但您尚未定义变量
text
,以表示基于我上传的照片的任何内容,修复该错误的解决方案是什么?解决方案的可能副本是使用要在wordcloud中显示的单词创建变量
text
,即
text=“Hello World of Word Cloud
text = ''

for i in range(len(df)):
    text += df.iloc[i,2]
.generate(df.text)