Visualise grouped elements


I am doing an analysis of how revenue changed over time (I grouped months and years and now I would like to visualise how the revenue changed over time. Barh plot works fine, but I would like to use multiple line chart for this (comparing how revenue changed over months in 2017, 2018 and 2019).
My code:
sales = task[[‘saleDate’,‘purchasePrice’]]
grouped = sales.groupby(‘saleDate’)[‘purchasePrice’]
task_stats = grouped.agg(np.sum)
pv_task_stats = sales.pivot_table([‘purchasePrice’], ‘saleDate’, aggfunc=np.sum)

Do I have to save this pivot table to dataframe or do you have any other idea on how to do this?

Thank you in advace.

You pivot table is already a dataframe. It’s not clear from your example what would you like to achieve.

To create a line plot you could use the following code: pv_task_stats.plot().

Hi @Malgorzata:

As @artur.sannikov96 has said, your example is not clear. Please provide a question link and format your code according to these guidelines so we can better assist you!


1 Like