GMARTINEZMILLA commited on
Commit
3888972
1 Parent(s): dd337a5

bugfix: Manufacturers Alerts

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -472,8 +472,14 @@ elif page == "Customer Analysis":
472
  st.subheader("This looks great!")
473
  st.info("Your customer did exceed predicted sales from the following brands:")
474
 
 
 
 
 
 
 
475
  # Identify manufacturers that exceeded predicted sales
476
- overperforming_manufacturers = results[results['ventas_reales'] > results['ventas_predichas']].copy()
477
 
478
  if not overperforming_manufacturers.empty:
479
  # Calculate the extra amount (difference between actual and predicted sales)
@@ -554,8 +560,14 @@ elif page == "Customer Analysis":
554
  st.subheader("You might need to check this!")
555
  st.warning("Your customer was expected to buy more products from the following brands:")
556
 
 
 
 
 
 
 
557
  # Identify manufacturers that didn't meet predicted sales
558
- underperforming_manufacturers = results[results['ventas_reales'] < results['ventas_predichas']].copy()
559
 
560
  if not underperforming_manufacturers.empty:
561
  # Calculate the missed amount
 
472
  st.subheader("This looks great!")
473
  st.info("Your customer did exceed predicted sales from the following brands:")
474
 
475
+ # Group results by manufacturer to calculate the total predicted and actual sales
476
+ grouped_results = results.groupby('marca_id_encoded').agg({
477
+ 'ventas_reales': 'sum',
478
+ 'ventas_predichas': 'sum'
479
+ }).reset_index()
480
+
481
  # Identify manufacturers that exceeded predicted sales
482
+ overperforming_manufacturers = grouped_results[grouped_results['ventas_reales'] > grouped_results['ventas_predichas']].copy()
483
 
484
  if not overperforming_manufacturers.empty:
485
  # Calculate the extra amount (difference between actual and predicted sales)
 
560
  st.subheader("You might need to check this!")
561
  st.warning("Your customer was expected to buy more products from the following brands:")
562
 
563
+ # Group results by manufacturer to calculate the total predicted and actual sales
564
+ grouped_results = results.groupby('marca_id_encoded').agg({
565
+ 'ventas_reales': 'sum',
566
+ 'ventas_predichas': 'sum'
567
+ }).reset_index()
568
+
569
  # Identify manufacturers that didn't meet predicted sales
570
+ underperforming_manufacturers = grouped_results[grouped_results['ventas_reales'] < grouped_results['ventas_predichas']].copy()
571
 
572
  if not underperforming_manufacturers.empty:
573
  # Calculate the missed amount