Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
d634aab
1
Parent(s):
0671d23
feat: updated website
Browse files
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 |
-
|
216 |
-
st.
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
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":
|