Skip to content

Instantly share code, notes, and snippets.

@karamanbk
Last active January 3, 2024 22:36
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save karamanbk/314d3d5483b9be1d2cc7f9694368f3bc to your computer and use it in GitHub Desktop.
Save karamanbk/314d3d5483b9be1d2cc7f9694368f3bc to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Ulisesp91
Copy link

Hi Barış, thanks for the code it is very helpful for me.

I am not getting right the Monthly Order Count of orders in my df. So I think there ir a mistake in the code, look:

In [28]: tx_monthly_sales = tx_uk.groupby('InvoiceYearMonth')['Quantity'].sum().reset_index() you are adding all the qty of products sold.

Also, look a the output table the # of transactions says 298,101 which is more than your whole df.

InvoiceYearMonth Quantity
201012 298101
201101 237381
201102 225641
201103 279843
201104 257666
201105 306452
201106 258522
201107 324129
201108 319804
201109 458490
201110 455612
201111 642281
201112 199907

Unless you mean this table is the total count of the # of products sold, which I think it's the value that we obtained.

Also the monthly order average, I would way that it should say that is the average price of the product per month because the value obtained is not taking into account the whole transaction but each product and obtains the mean.

In [33]: tx_monthly_order_avg = tx_uk.groupby('InvoiceYearMonth')['Revenue'].mean().reset_index()

I am new with python so, I really have no idea how to obatin the average revenue per order and the total number of orders, ja!

Please let me know your comments, probably I am just confused.

Thank you again for this analysis, it's pretty good.

@jeanetamcfoam
Copy link

Hi Baris,

Thank you so much for this wonderful report!

I was wondering why I am getting such error for:

Line Number 95

total_user_count = tx_retention[tx_retention.MinPurchaseYearMonth == selected_month].MinPurchaseYearMonth.count()

error:
AttributeError: 'DataFrame' object has no attribute 'MinPurchaseYearMonth'

Thanks in advance,
Jeanet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment