尝试创建图表
Trying to Create a Graph
我可以使用 Jupyter 创建图表,但是当我使用 Python 3.6.4 shell 编写此代码时,我收到了以下信息:
`enter code here
`File "<string>", line 1, in <module>
File "C:\Users\RJ\AppData\Local\Programs\Python\Python36-32\lib\idlelib\run.py", line 144, in main
ret = method(*args, **kwargs)
File "C:\Users\RJ\AppData\Local\Programs\Python\Python36-32\lib\idlelib\run.py", line 474, in runcode
exec(code, self.locals)
文件“”,第 1 行,位于
enter image description here
我明白是什么问题了。首先,你实际上没有任何错误。将您的行更改为以下内容:
sns_plot = sns.distplot(df["24-Hour Passes Purchased (midnight to 11:59pm)"])
sns_plot.savefig("output.png")
然后您会在磁盘上找到一个名为 "output.png" 的文件,您可以在其中查看情节。
当我最初说您应该显示回溯错误时,我认为 sns.distplot
是在抛出错误。这里情况不同。所以你不需要导入回溯和打印回溯,因为 Python 解释器从来没有引发过任何异常。
其次,您应该考虑使用 Jupyter Notebook,因为它会让这个过程更具交互性。
希望对您有所帮助!
我可以使用 Jupyter 创建图表,但是当我使用 Python 3.6.4 shell 编写此代码时,我收到了以下信息:
`enter code here
`File "<string>", line 1, in <module>
File "C:\Users\RJ\AppData\Local\Programs\Python\Python36-32\lib\idlelib\run.py", line 144, in main
ret = method(*args, **kwargs)
File "C:\Users\RJ\AppData\Local\Programs\Python\Python36-32\lib\idlelib\run.py", line 474, in runcode
exec(code, self.locals)
文件“”,第 1 行,位于 enter image description here
我明白是什么问题了。首先,你实际上没有任何错误。将您的行更改为以下内容:
sns_plot = sns.distplot(df["24-Hour Passes Purchased (midnight to 11:59pm)"])
sns_plot.savefig("output.png")
然后您会在磁盘上找到一个名为 "output.png" 的文件,您可以在其中查看情节。
当我最初说您应该显示回溯错误时,我认为 sns.distplot
是在抛出错误。这里情况不同。所以你不需要导入回溯和打印回溯,因为 Python 解释器从来没有引发过任何异常。
其次,您应该考虑使用 Jupyter Notebook,因为它会让这个过程更具交互性。
希望对您有所帮助!