Skip to content
Advertisement

Show Average Per Month

I have the following dataset:

Datset example

I am trying to create a graph using matplotlib that shows the average number of task by Month & Year.

I was able to complete the calculations for average and was converted the date column to show only the Month and Year. However, when I go to plot, only the year appears.

JavaScript

Plotting:

JavaScript

How do I show the month and year in the graph?

Advertisement

Answer

The data you have provided is very small (3 rows with same date). So, I couldn’t create a month-wise plot. So, this is the data I used.

JavaScript

You have used avg/avg1 and Task/Tasks alternatively. So, I just used avg and Task instead. This is the updated code

JavaScript

…which gives below line plot. You can see both month and year. Hope this is what you are looking for.

enter image description here

Also, you can use the below code to create a bar chart, which I think might be more relevant in your case. There are many many other graphs you can try out as well…

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement