python - 情节没有出现在 Pandas 中
问题描述
我正在按照教程学习数据分析以绘制图表,这是我的代码
import pandas as pd
df=pd.read_csv("avocado.csv")
df["Date"]=pd.to_datetime(df["Date"])
albany_df=df[df["region"]=="Albany"]
albany_df.set_index("Date",inplace=True)
albany_df["AveragePrice"].plot()
代码没有错误,因为**没有错误消息**只有这一行出现(没有图表)
<matplotlib.axes._subplots.AxesSubplot at 0x2556f2158d0>
解决方案
您需要导入 matplotlib,并执行 show() :
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_csv("avocado.csv")
df["Date"]=pd.to_datetime(df["Date"])
albany_df=df[df["region"]=="Albany"]
albany_df.set_index("Date",inplace=True)
albany_df["AveragePrice"].plot()
plt.show()
推荐阅读
- laravel - 我在 Fedora 34、Laravel、SELinux 中禁止从 Apache (httpd) 访问
- python - Azure /bin/sh 中的 Docker 容器:1:[gunicorn,:未找到
- vue.js - Storage.put() 抛出 - AWSS3Provider - 上传错误 TypeError:无法读取未定义的属性“byteLength”
- javascript - 如何解决 vue 键盘事件绑定问题?
- terraform - 使用 terraform 使用预留实例创建 EKS
- flutter - 检测进入页面事件 Flutter
- javascript - 如何使用node.js在axios请求中添加带有formData的文件
- r - 如何在 R 中排除具有相同 ID 的调查中的用户进行计算?
- javascript - 如何在 gtmetrix 中快速加载网站图标
- excel - 几次迭代后从 SAP 导出的文件错误中复制数据