-1

I have a data frame like so. I am trying to make a plot with the mean of 'number' for each year on the y and the year on the x. I think what I have to do to do this is make a new data frame with 2 columns 'year' and 'avg number' for each year. How would I go about doing that?

    year    number  
0   2010    40  
1   2010    44
2   2011    33  
3   2011    32  
4   2012    34 
5   2012    56

1 Answers1

0

When opening a question about pandas please make sure you following these guidelines: How to make good reproducible pandas examples. It will help us reproduce your environment.

Assuming your dataframe is stored in the df variable:

df.groupby('year').mean().plot()
arhr
  • 1,505
  • 8
  • 16