GMARTINEZMILLA commited on
Commit
d634aab
1 Parent(s): 0671d23

feat: updated website

Browse files
Files changed (1) hide show
  1. app.py +26 -12
app.py CHANGED
@@ -71,6 +71,12 @@ customer_clusters = pd.read_csv('predicts/customer_clusters.csv') # Load the cu
71
  df_agg_2024 = pd.read_csv('predicts/df_agg_2024.csv')
72
  pca_data_5 = pd.read_csv('pca_data.csv')
73
 
 
 
 
 
 
 
74
  # Ensure customer codes are strings
75
  df['CLIENTE'] = df['CLIENTE'].astype(str)
76
  nombres_proveedores['codigo'] = nombres_proveedores['codigo'].astype(str)
@@ -212,18 +218,26 @@ if page == "Summary":
212
 
213
  # Right Column (Blue): Key Metrics Overview and Data Preparation Summary
214
  with col3:
215
- st.markdown('#### Key Metrics Overview')
216
- st.write("""
217
- - **Customers Analyzed**: 4,000
218
- - **Suppliers Analyzed**: 400
219
- - **Invoice Lines Processed**: 800,000
220
- """)
221
-
222
- st.markdown('#### Data Preparation Summary')
223
- st.write("""
224
- - Cleaned and standardized product codes and descriptions.
225
- - Excluded customers with fewer than 12 purchases or sales below €1,200.
226
- """)
 
 
 
 
 
 
 
 
227
 
228
  # Customer Analysis Page
229
  elif page == "Customer Analysis":
 
71
  df_agg_2024 = pd.read_csv('predicts/df_agg_2024.csv')
72
  pca_data_5 = pd.read_csv('pca_data.csv')
73
 
74
+ # Generamos la columna total_sales
75
+ ventas_clientes['total_sales'] = ventas_clientes[['VENTA_2021', 'VENTA_2022', 'VENTA_2023']].sum(axis=1)
76
+ # Ordenar los clientes de mayor a menor según sus ventas totales
77
+ ventas_top_100 = ventas_clientes.sort_values(by='total_sales', ascending=False).head(100)
78
+
79
+
80
  # Ensure customer codes are strings
81
  df['CLIENTE'] = df['CLIENTE'].astype(str)
82
  nombres_proveedores['codigo'] = nombres_proveedores['codigo'].astype(str)
 
218
 
219
  # Right Column (Blue): Key Metrics Overview and Data Preparation Summary
220
  with col3:
221
+ # Mostrar la tabla con los 100 mejores clientes
222
+ st.markdown('#### Top 100 Clients by Total Sales')
223
+
224
+ # Configurar columnas para mostrar los clientes y las ventas totales
225
+ st.dataframe(ventas_top_100[['codigo_cliente', 'total_sales']],
226
+ column_order=("codigo_cliente", "total_sales"),
227
+ hide_index=True,
228
+ width=None,
229
+ column_config={
230
+ "codigo_cliente": st.column_config.TextColumn(
231
+ "Client Code",
232
+ ),
233
+ "total_sales": st.column_config.ProgressColumn(
234
+ "Total Sales (€)",
235
+ format="%d",
236
+ min_value=0,
237
+ max_value=ventas_top_100['total_sales'].max(),
238
+ bar_color="blue", # Cambiar el color si lo prefieres
239
+ )}
240
+ )
241
 
242
  # Customer Analysis Page
243
  elif page == "Customer Analysis":