Advertisement
dollarortwo

ooohhhhlalalalala

Nov 14th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. xl = pd.ExcelFile("SalesDataFull.xlsx")
  4. OrdersOnlyData = xl.parse("Orders")
  5.  
  6. while True:
  7. print("\nView Products by Month - press a. View Product by Quarter - press b.")
  8. user_decision = input("Which type of data would you like to access? ")
  9.  
  10. while user_decision == "":
  11. user_decision = input("Which type of data would you like to access? ")
  12.  
  13. if user_decision == "a":
  14. print()
  15. print("Profit by Month")
  16. print("View 10 Most Popular Products - press a. View 10 Least Popular Products - press b. ")
  17. month_choice = input("Which type of data do you like access to? ")
  18.  
  19. while month_choice == "":
  20. month_choice = input("Which type of data would you like to access? ")
  21.  
  22. if month_choice == "a":
  23. df_month = OrdersOnlyData["Order Date"].dt.month
  24. OrdersOnlyData["Month"] = df_month
  25. product_sales = OrdersOnlyData[["Product Name", "Month", "Profit"]]
  26. product_sales_sum = product_sales.groupby(by="Month" and "Product Name").sum().sort_values(by=["Profit"], ascending=False).reset_index()
  27. print(product_sales_sum.head(10).round(2))
  28. exit_program = input("Exit Program? (Y/N): ")
  29. if exit_program.lower() == "y":
  30. print("Goodbye!")
  31. break
  32.  
  33. if month_choice == "b":
  34. df_month = OrdersOnlyData["Order Date"].dt.month
  35. OrdersOnlyData["Month"] = df_month
  36. product_sales = OrdersOnlyData["Product Name", "Month" "Profit"]
  37. product_sales_sum = product_sales.groupby(by="Month" and "Product Name").sum().sort_values(by=["Profit"], ascending=False).reset_index()
  38. print(product_sales_sum.tail(10).round(2))
  39. year = input("Do you want to see data by the year? ")
  40. if year.lower() == 'y':
  41. orders2014 = OrdersOnlyData.loc[OrdersOnlyData["Order Date"] > "2014-01-01"]
  42. print(orders2014.head(10).round(2))
  43. exit_program = input("Exit Program? (Y/N): ")
  44. if exit_program.lower() == 'y':
  45. print("Goodbye!")
  46. break
  47.  
  48. if user_decision == "b":
  49. print("Profit by Quarter.")
  50. quarter_choice = input("View 10 Most Popular Products - press a. View 10 Least Popular Products - press b.")
  51.  
  52. while quarter_choice == "":
  53. quarter_choice = input("View 10 Most Popular Products - press a. View 10 Least Popular Products - press b.")
  54.  
  55. if quarter_choice == "a":
  56. df_quarter = OrdersOnlyData["Order Data"].dt.quarter
  57. OrdersOnlyData["Quarter"] = df_quarter
  58. product_sales = OrdersOnlyData[["Product Name", "Quarter", "Profit"]]
  59. product_sales_sum = product_sales.groupby(by="Quarter" and "Product Name").sum().sort_values(by=["Profit"], ascending=False)
  60. product_sales_sum = product_sales.reset_index()
  61. print(product_sales_sum.head(10).round(2))
  62. exit_program = input("Exit Program? (Y/N): ")
  63. if exit_program.lower() == "y":
  64. print("Goodbye!")
  65. break
  66.  
  67. if quarter_choice == "b":
  68. df_quarter = OrdersOnlyData["Order Data"].dt.quarter
  69. OrdersOnlyData["Quarter"] = df_quarter
  70. product_sales = OrdersOnlyData["Product Name", "Quarter", "Profit"]
  71. product_sales_sum = product_sales.groupby(by="Quarter" and "Product Name").sum().sort_values(by=["Profit"], ascending=False)
  72. product_sales_sum = product_sales.reset_index()
  73. print(product_sales_sum.tail(10).round(2))
  74. exit_program = input("Exit Program? (Y/N): ")
  75. if exit_program.lower() == "y":
  76. print("Goodbye!")
  77. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement