GMARTINEZMILLA commited on
Commit
3ac8646
·
1 Parent(s): 36df00a

bugfix: fixed CLIENTE for Cliente

Browse files
Files changed (1) hide show
  1. app.py +27 -19
app.py CHANGED
@@ -286,18 +286,22 @@ elif page == "Articles Recommendations":
286
  if option == "By Purchase History":
287
  st.warning("Option not available... aún")
288
  elif option == "By Current Basket":
289
- st.write("Enter the items in the basket:")
290
-
291
- # Input para los artículos y unidades
292
- items = st.text_input("Enter items (comma-separated):").split(',')
293
- quantities = st.text_input("Enter quantities (comma-separated):").split(',')
 
 
 
 
 
294
 
295
  if st.button("Calcular"): # Añadimos el botón "Calcular"
296
- # Crear una lista de artículos basada en la entrada
297
- new_basket = [item.strip() for item in items]
298
 
299
- # Asegurarse de que las longitudes de artículos y cantidades coincidan
300
- if len(new_basket) == len(quantities):
301
  # Procesar la lista para recomendar
302
  recommendations_df = recomienda(new_basket)
303
 
@@ -307,21 +311,25 @@ elif page == "Articles Recommendations":
307
  else:
308
  st.warning("No recommendations found for the provided basket.")
309
  else:
310
- st.warning("The number of items must match the number of quantities.")
311
  else:
312
  st.write(f"### Customer {customer_code} is not a loyal customer.")
313
- st.write("Recommendation based on the basket. Please enter the items:")
 
 
 
 
314
 
315
- # Input para los artículos y unidades
316
- items = st.text_input("Enter items (comma-separated):").split(',')
317
- quantities = st.text_input("Enter quantities (comma-separated):").split(',')
 
318
 
319
  if st.button("Calcular"): # Añadimos el botón "Calcular"
320
- # Crear una lista de artículos basada en la entrada
321
- new_basket = [item.strip() for item in items]
322
 
323
- # Asegurarse de que las longitudes de artículos y cantidades coincidan
324
- if len(new_basket) == len(quantities):
325
  # Procesar la lista para recomendar
326
  recommendations_df = recomienda(new_basket)
327
 
@@ -331,4 +339,4 @@ elif page == "Articles Recommendations":
331
  else:
332
  st.warning("No recommendations found for the provided basket.")
333
  else:
334
- st.warning("The number of items must match the number of quantities.")
 
286
  if option == "By Purchase History":
287
  st.warning("Option not available... aún")
288
  elif option == "By Current Basket":
289
+ st.write("Select the items and assign quantities for the basket:")
290
+
291
+ # Mostrar lista de artículos disponibles
292
+ available_articles = productos['ARTICULO'].unique()
293
+ selected_articles = st.multiselect("Select Articles", available_articles)
294
+
295
+ # Crear inputs para ingresar las cantidades de cada artículo seleccionado
296
+ quantities = {}
297
+ for article in selected_articles:
298
+ quantities[article] = st.number_input(f"Quantity for {article}", min_value=0, step=1)
299
 
300
  if st.button("Calcular"): # Añadimos el botón "Calcular"
301
+ # Crear una lista de artículos basada en la selección
302
+ new_basket = [f"{article} x{quantities[article]}" for article in selected_articles if quantities[article] > 0]
303
 
304
+ if new_basket:
 
305
  # Procesar la lista para recomendar
306
  recommendations_df = recomienda(new_basket)
307
 
 
311
  else:
312
  st.warning("No recommendations found for the provided basket.")
313
  else:
314
+ st.warning("Please select at least one article and set its quantity.")
315
  else:
316
  st.write(f"### Customer {customer_code} is not a loyal customer.")
317
+ st.write("Select items and assign quantities for the basket:")
318
+
319
+ # Mostrar lista de artículos disponibles
320
+ available_articles = productos['ARTICULO'].unique()
321
+ selected_articles = st.multiselect("Select Articles", available_articles)
322
 
323
+ # Crear inputs para ingresar las cantidades de cada artículo seleccionado
324
+ quantities = {}
325
+ for article in selected_articles:
326
+ quantities[article] = st.number_input(f"Quantity for {article}", min_value=0, step=1)
327
 
328
  if st.button("Calcular"): # Añadimos el botón "Calcular"
329
+ # Crear una lista de artículos basada en la selección
330
+ new_basket = [f"{article} x{quantities[article]}" for article in selected_articles if quantities[article] > 0]
331
 
332
+ if new_basket:
 
333
  # Procesar la lista para recomendar
334
  recommendations_df = recomienda(new_basket)
335
 
 
339
  else:
340
  st.warning("No recommendations found for the provided basket.")
341
  else:
342
+ st.warning("Please select at least one article and set its quantity.")