Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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 不带';不显示_Python_Pandas - Fatal编程技术网

Python 不带';不显示

Python 不带';不显示,python,pandas,Python,Pandas,我有这个df: wind speed - Km/Hr Wind Dir counts Frequency 0 0 - <2 E 1278 0.018459 1 0 - <2 ENE 1889 0.027284

我有这个
df

                  wind speed - Km/Hr             Wind Dir  counts    Frequency
    0                         0 - <2                    E    1278    0.018459
    1                         0 - <2                  ENE    1889    0.027284
    2                         0 - <2                  ESE    1057    0.015267
    3                         0 - <2                    N    1600    0.023110
    4                         0 - <2                   NE    2172    0.031371
.............                 ......                  ...    ....    ........
当我运行代码时,图没有显示,但是创建了一个名为fig的变量。因此,我在变量中单击鼠标右键(在spyder控制台中),然后单击“使用对象资源管理器查看”选项,但该图不会以任何方式显示

你介意帮我吗


提前谢谢。

如果您在Jupyter之类的工具下运行它,它会工作的。但由于它是Spyder,这取决于您希望它是静态图像还是交互式图像。但是您需要查看/使用渲染器。例如,您可以在浏览器中以html文件的形式打开,并保留交互式/悬停部分:

import pandas as pd



df = pd.DataFrame([['0 - <2','E',1278,0.018459],
['0 - <2','ENE',1889,0.027284],
['0 - <2','ESE',1057,0.015267],
['0 - <2','N',1600,0.023110],
['0 - <2','NE',2172,0.031371]],columns = ['wind speed - Km/Hr','Wind Dir','counts','Frequency'])


import plotly.express as px
fig = px.bar_polar(df, r="Frequency", theta="Wind Dir",
                   color="wind speed - Km/Hr", template="plotly_dark",
                   color_discrete_sequence= px.colors.sequential.Plasma_r)
fig.write_html("C:/test/file.html")
将熊猫作为pd导入

df=pd.DataFrame([['0-您可以随时导出它,例如使用fig.savefig('windrose.png')@Krzysztofik我收到了这个错误消息:AttributeError:'Figure'对象没有属性'savefig'@Krzysztofik这是变量的类型:graph_objs.\u Figure.FigureMy bad,我脑子里有matplotlib。。。
import pandas as pd



df = pd.DataFrame([['0 - <2','E',1278,0.018459],
['0 - <2','ENE',1889,0.027284],
['0 - <2','ESE',1057,0.015267],
['0 - <2','N',1600,0.023110],
['0 - <2','NE',2172,0.031371]],columns = ['wind speed - Km/Hr','Wind Dir','counts','Frequency'])


import plotly.express as px
fig = px.bar_polar(df, r="Frequency", theta="Wind Dir",
                   color="wind speed - Km/Hr", template="plotly_dark",
                   color_discrete_sequence= px.colors.sequential.Plasma_r)
fig.write_html("C:/test/file.html")