[英]Graph does not plot correctly
I have studied, Python, Kivy, Postgres, Peewee, Django, Pandas and now Dash.我研究过,Python, Kivy, Postgres, Peewee, Django, Z251D2BBFE9A3B7845E 现在还有9DBBFE9A3B7845E。
I only started this way because in Telegram and Whatsapp groups I have been asked a lot of questions about my knowledge that are running things over.我只是以这种方式开始的,因为在 Telegram 和 Whatsapp 组中,我被问到很多关于我的知识的问题,这些问题正在运行。
But you are right, I usually do that, however, I think that my doubt could be answered without enigmas, without hurt anyone but I want to say that I am not a professional programmer, I don't have a paid activity, everything is fun.但是你是对的,我通常这样做,但是,我认为我的疑问可以在没有谜团的情况下得到解答,不会伤害任何人但我想说我不是专业程序员,我没有付费活动,一切都是乐趣。
Let's get to what really matters:让我们来看看真正重要的事情:
I can't plot a line graph as I have been told that I am indexing the data, I don't know where I am doing this.我不能 plot 折线图,因为我被告知我正在索引数据,我不知道我在哪里做这个。
Can someone help me plot this chart without errors?有人可以帮我 plot 这个图表没有错误吗?
For creating a graph, it is usually used with matplotlib.对于创建图形,它通常与 matplotlib 一起使用。 I looked at your code and successfully run it, but I do not think this is something that you like to do, so I plot your data by using matplotlib.
我查看了您的代码并成功运行它,但我认为这不是您喜欢做的事情,所以我使用 matplotlib plot 您的数据。
MesAno has type string, so let's convert to something comparable. MesAno 具有字符串类型,所以让我们转换为类似的东西。
from datetime import datetime
datetime.strptime(str(movimento_por_mes_vendedores['MesAno'].iloc[1]), '%Y-%m')
movimento_por_mes_vendedores['MesAno'] = movimento_por_mes_vendedores['MesAno'].fillna(0) #NANを0置換
for i in range(0, movimento_por_mes_vendedores.shape[0]):
movimento_por_mes_vendedores['MesAno'].iloc[i] = datetime.strptime(str(movimento_por_mes_vendedores['MesAno'].iloc[i]), '%Y-%m')
And store those data in list并将这些数据存储在列表中
postDatedList = []
for i in range(0, movimento_por_mes_vendedores.shape[0]):
postDatedList.append(datetime(
movimento_por_mes_vendedores['MesAno'].iloc[i].year,
movimento_por_mes_vendedores['MesAno'].iloc[i].month,
movimento_por_mes_vendedores['MesAno'].iloc[i].day
))
debitAmountList = []
for i in range(0, movimento_por_mes_vendedores.shape[0]):
debitAmountList.append(movimento_por_mes_vendedores['qtitem'].iloc[i])
print("post shape: " + str(len(debitAmountList)))
Then you can compare those two with matplotlib然后您可以将这两个与 matplotlib 进行比较
x = postDatedList
y = debitAmountList
fig = plt.figure(figsize=(30,10), dpi=100, facecolor='white')
ax = fig.add_subplot(111)
ax.bar(x, y, width=20, align="center")
ax.xaxis_date()
plt.title('Financial Graph')
plt.xlabel("Date")
plt.ylabel("Amount")
plt.grid(True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.