python 3.x - Scatter plots from averaging a columns values -


i'm working 2 columns csv file: month_num , freight_in_(tonnes)

i'm attempting plot average value of freight each month 1987 2016. can show each months average freight in, in table format i'm struggling show in scatter plot.

here current code.

from matplotlib import pyplot plt  import pandas pd  df = pd.read_csv('citypairs.csv')  month = df.groupby(['month_num'])['freight_in_(tonnes)'] month.mean()  plt.scatter(df['month_num'], df['freight_in_(tonnes)']) plt.show() 

try this: df.groupby(['month_num']).mean().reset_index().plot(kind='scatter',x='month_num',y='freight_in_(tonnes)')


Comments

Popular posts from this blog

javascript - How to bind ViewModel Store to View? -

recursion - Can every recursive algorithm be improved with dynamic programming? -

python - Alternative to referencing variable before assignment -