pandas 在jupyter notebook中使用python无法工作的代码[已关闭]

8xiog9wr  于 5个月前  发布在  Python
关注(0)|答案(1)|浏览(45)

**已关闭。**此问题需要debugging details。目前不接受回答。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答问题。
2天前关闭。
Improve this question
我的python代码在python notebook中给了我一个在输出中需要的图形,相反,它给了我错误。我使用了Kaggle的数据集来创建这个图形。
这里是代码

pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('australia_bushfire.csv')
df

group_by_date = df.groupby('acq_date')['confidence'].mean().reset_index()
group_by_date

label = group_by_date['acq_date']
value = group_by_date['confidence']

plt.subplots(figsize = (19,8))
plt.plot(label, value, label = "Average confidence as per date", linewidth = 3.0)

plt.xlabel('Dates')
plt.xticks(rotation = 'vertical')
plt.ylabel('confidence')
plt.title('Average confidence as per date', fontsize = 20)
plt.legend()

plt.show()

字符串
https://www.kaggle.com/datasets/carlosparadis/fires-from-space-australia-and-new-zeland
这是链接到数据集有人pls帮助我解决这个问题。

bjg7j2ky

bjg7j2ky1#

确保在编写代码时注意语法,并且在发现错误时,在描述中指出它们是至关重要的。
乍一看,你的代码中几乎没有什么错别字。
在第一行中,您应该调用'import'关键字

import pandas as pd

字符串
另外,请确保删除那些空的未分配的'df'和'group_by_date'行,它应该像这样结束:

df = pd.read_csv('australia_bushfire.csv')

group_by_date = df.groupby('acq_date')['confidence'].mean().reset_index()

相关问题