无法使用pycharm中的plotly打印数据帧数据

2024-04-24 04:34:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在pycharm中使用plotly绘制熊猫数据帧数据,但它不起作用。下面是代码片段

import plotly.plotly as py
import pandas as pd
import numpy as np
import cufflinks as cf

cf.go_offline()

df = pd.DataFrame(np.random.randn(100,4),columns='A B C D'.split())
print(df.head())

df.iplot()

当我在pycharm中运行上述代码时,它抛出了错误

plotly.exceptions.PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, '', we expected it to start with 'https://plot.ly'.
Run help on this function for more information.

不确定这里到底出了什么问题

有人能帮我吗

谢谢


Tags: theto数据代码importreyoudf
1条回答
网友
1楼 · 发布于 2024-04-24 04:34:51

您的代码,实际上是,在Jupyter笔记本中运行良好,并生成以下绘图:

enter image description here

因此,问题归结为如何在PyCharm中运行代码。Python控制台?也许是伊皮顿?为了让plotly和iplot()离线运行,我认为您必须在Jupyter笔记本中运行这个特定的代码段。但是你也可以在PyCharm中这样做

enter image description here

您可能需要进行一些额外的安装,但这一点也不难

相关问题 更多 >