Graphic multindex pandas

Asked

Viewed 34 times

0

Hello,

I have the following dataframe: Where I have a period of 3 years.

inserir a descrição da imagem aqui

I would like to be filling a chart of agupado VALUE per month and year, I did as follows, but it did not work.

df.groupby(['MES','ANO','VALOR']).sum().plot()

where I’m going wrong?

Thank you!

1 answer

0


What result do you want? The aggregation order changes the final result:

df.groupby(['ANO','MES'])['VALOR'].sum().plot(kind='line')
  • ah yes, it worked, thank you. Now it falls into another problem, which would be in the graph generation. wanted to plot on the Y axis the VALUE column and on the X axis the ordered columns [year and month], but it wasn’t the way I wanted it, I would have to create a new topic for help?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.