Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Product Sales by Region with most profit
- #find which region has the most sales
- region_profit_columns = SalesData [["Region", "Sales"]]
- region_total_sales = region_profit_columns.groupby(by = "Region").sum().sort_values(by = "Sales")
- print(region_total_sales)
- #find which region has the most profit
- region_profit_columns = SalesData [["Region", "Profit"]]
- region_total_profit = region_profit_columns.groupby(by = "Region").sum().sort_values(by = "Profit")
- print(region_total_profit)
- #find product sales by region
- region_profit_subCat = SalesData [["Region", "Profit", "Sub-Category"]]
- regions = SalesData.Region.unique()
- #for each value in regions:
- for region in regions:
- region_profit = region_profit_subCat.loc[region_profit_subCat["Region"] == region]
- region_total_profit = region_profit.groupby(by = "Sub-Category").sum().sort_values(by = "Profit", ascending = False)
- region_total_profit = region_total_profit.reset_index()
- print("The most profitable 5 sub-categories in " + region + " are: ")
- print(region_total_profit.head(5))
- print(Decorating)
- """
- Created on Thu Nov 14 15:33:30 2019
- @author: Gai
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement