We Have sample data for creating simple Line graphs. You can use this tutorial to generate CSV.
TicketID Priority TicketTime Year Month Week Hour 0 TICKET000 Priority-1 2016-01-01 00:00:00 2016 1 53 0 1 TICKET001 Priority-5 2016-01-01 01:00:00 2016 1 53 1 2 TICKET002 Priority-3 2016-01-01 02:00:00 2016 1 53 2 3 TICKET003 Priority-4 2016-01-01 03:00:00 2016 1 53 3 4 TICKET004 Priority-3 2016-01-01 04:00:00 2016 1 53 4 5 TICKET005 Priority-4 2016-01-01 05:00:00 2016 1 53 5 6 TICKET006 Priority-2 2016-01-01 06:00:00 2016 1 53 6 7 TICKET007 Priority-5 2016-01-01 07:00:00 2016 1 53 7 8 TICKET008 Priority-4 2016-01-01 08:00:00 2016 1 53 8 9 TICKET009 Priority-3 2016-01-01 09:00:00 2016 1 53 9
Now, Lets look in for Chart creation.
We can use the matplotlib package.
import pandas as pd import datetime as dt import matplotlib.pyplot as plt
Reading CSV as
# Reading Data from CSV df=pd.read_csv('GeneratedTickets.csv',low_memory=False)
Convert the Date Fields.
# Converting the DateField in CSV to datetime. df["TicketTime"]=pd.to_datetime(df["TicketTime"])
Make additional Fields in the Pandas DataFrame.
# Extracting Year, Month, Week, Hours from Date Field df['Year'] = df['TicketTime'].dt.year df['Month'] = df['TicketTime'].dt.month df['Week'] = df['TicketTime'].dt.week df['Hour'] = df['TicketTime'].dt.hour
Grouping Data: We will group by Priority, Week, Month, Hours – {
Number of observations in each – Priority, Month, Week, Hour can be done using .size() method of data frame.
df_grpBypr= df.groupby(['Priority','Month','Week','Hour']).size().reset_index(name="TicketCount")
Extracting on Jan Month and First Week.
df_grpBypr=df_grpBypr[df_grpBypr[ df_grpBypr['Month'] == 1] ['Week'] ==1]
Looking for Priroity-1 Data only.
df_Priority = df_grpBypr[ df_grpBypr['Priority'] == 'Priority-1']
Creating a line chart.
plt.title('Weekly Priority Trend') plt.xlabel('Hours') plt.ylabel('Tickets Recieved') plt.plot(df_Priority['Hour'], df_Priority['TicketCount'],marker='o', linestyle='--', color='r', label='Circle') plt.show()
Cant Upload the pictures
Advertisements