Skip to content

Instantly share code, notes, and snippets.

Last active January 5, 2023 09:12
What would you like to do?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.

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()

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

Thanks in advance,

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