[英]Plot bar chart in python using csv data in pandas & Matplotlib
My bar chart is not showing correctly.我的条形图显示不正确。 I have csv data as below.
我有如下的 csv 数据。 I would like to plot bar chart using group by date and categories Key value with Count.
我想使用按日期和类别分组的键值和计数来绘制条形图。 So, every date will be group by and it will categories the key value with their Count.
因此,每个日期都将被分组,并将使用它们的计数对键值进行分类。 Please assist with below code.
请协助以下代码。 I am new and learning python myself.
我是新手,自己在学习 python。
My csv collect_data.csv
data:我的 csv
collect_data.csv
数据:
Date,Key,Count
14-10-2020,created,5
14-10-2020,moved,3
14-10-2020,modified,3
14-10-2020,deleted,5
17-10-2020,created,25
17-10-2020,moved,6
17-10-2020,modified,13
17-10-2020,deleted,25
18-10-2020,created,13
18-10-2020,modified,7
18-10-2020,moved,1
18-10-2020,deleted,13
My current bar chart:我当前的条形图:
My code:我的代码:
import matplotlib.pyplot as plt
import pandas as pd
def display_dashboard():
try:
df = pd.read_csv("collect_data.csv")
df.head()
df['Date'].value_counts().plot(kind='bar')
plt.title('File System Changed Based on Type of Event')
plt.ylabel('Total Count of Event Occurred')
plt.xlabel("DATE")
plt.show()
except FileNotFoundError:
print("Exception error: Missing files!")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.