I have a very simple pandas DataFrame with the following format:
date P1 P2 day
2015-01-01 190 1132 Thursday
2015-01-01 225 1765 Thursday
2015-01-01 3427 29421 Thursday
2015-01-01 945 7679 Thursday
2015-01-01 1228 9537 Thursday
2015-01-01 870 6903 Thursday
2015-01-02 785 4768 Friday
2015-01-02 1137 7065 Friday
2015-01-02 175 875 Friday
where P1 and P2 are different parameters of interest. I would like to create a bar graph that looks like this for each P1 and P2. As shown in the data, I have several values for each day. I would like to average the given values for a given day, then plot against day of week (so that the averaged value for Monday week 1 gets added to Monday week 2, etc.).
I'm new to python and my current method is quite nasty, involving several loops. I currently have two dedicated portions of code - one to do the averages and another to go through each day of the week one at a time and tally results for plotting. Is there a cleaner way to do this?