Python Forum
How to groupby Months showing average order value - Pandas & matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to groupby Months showing average order value - Pandas & matplotlib
#1
hello,
I am working with some data and would like to show the average order value (aov) for the different months. When I look at total revenue in the set period (£839736) and divide it by the total amount of transactions in that period (1232), it shows an average order value of £681. Is there a way this can be separated into individual months? As I know that the Average Order Value will be different for each month.
Code is below: the dataframe is stored in a variable called ikdf.
months = [month for month , df in ikdf.groupby('Month')]

invs = ikdf.groupby('Invoice ID').sum()
total_invs = len(invs)
rev = ikdf['Total Value'].sum()
aov = rev / total_invs


plt.bar(months, aov)
plt.xticks
plt.ylabel('AOV per month')
plt.xlabel('Months')
plt.show()[/inline][/python]

Sorry I cannot embed the output as an image into this box.
The output shows an average order value of £681 for all months.

Is there a way that I can separate this to show the different Average Order Values and how it varies each month?
Reply


Messages In This Thread
How to groupby Months showing average order value - Pandas & matplotlib - by Rwood90 - Oct-20-2020, 12:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  .py pandas matplotlib .xlsx files QubeStory 1 756 Mar-23-2023, 09:38 AM
Last Post: buran
  Use of groupby in a function with Pandas Paulman 0 927 Dec-03-2021, 04:56 PM
Last Post: Paulman
  Illegal instruction? working code for months? korenron 4 12,763 Aug-05-2021, 09:57 AM
Last Post: korenron
  Python Pandas: How do I average ONLY the data >1000 from several columns? JaneTan 0 1,446 Jul-17-2021, 01:34 PM
Last Post: JaneTan
  How to convert dates in odd format to months lokhtar 2 2,181 Apr-17-2021, 11:54 AM
Last Post: lokhtar
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,160 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib x-axis wrong order SchroedingersLion 4 4,176 Feb-23-2021, 05:42 PM
Last Post: nilamo
  python matplotlib groupby okpython 0 1,115 Feb-08-2021, 11:09 AM
Last Post: okpython
  How to calculate a months' 1st, 4th, 7th day and also 1st again? cananb 3 2,174 Nov-12-2020, 08:23 AM
Last Post: perfringo
  Matplotlib graphing help (dual y axis, groupby, filter) keml 0 2,165 Feb-07-2020, 02:35 AM
Last Post: keml

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020