Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
45bb8a5
1
Parent(s):
d496756
feat: generated files
Browse files
app.py
CHANGED
@@ -6,6 +6,10 @@ import plotly.graph_objects as go
|
|
6 |
# Configuración de la página principal
|
7 |
st.set_page_config(page_title="Customer Insights App", page_icon=":bar_chart:")
|
8 |
|
|
|
|
|
|
|
|
|
9 |
# Diseño de la página principal
|
10 |
st.title("Welcome to Customer Insights App")
|
11 |
st.markdown("""
|
@@ -28,55 +32,49 @@ elif page == "Customer Analysis":
|
|
28 |
Use the tools below to explore your customer data.
|
29 |
""")
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
#
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
categories
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
fig_sales = px.line(x=years, y=customer_sales, markers=True, title=f'Sales Over the Years for Customer {customer_code}')
|
75 |
-
fig_sales.update_layout(xaxis_title="Year", yaxis_title="Sales")
|
76 |
-
st.plotly_chart(fig_sales)
|
77 |
-
|
78 |
-
else:
|
79 |
-
st.warning(f"No data found for customer {customer_code}. Please check the code.")
|
80 |
|
81 |
# Página Customer Recommendations
|
82 |
elif page == "Customer Recommendations":
|
@@ -85,20 +83,20 @@ elif page == "Customer Recommendations":
|
|
85 |
Get tailored recommendations for your customers based on their purchasing history.
|
86 |
""")
|
87 |
|
88 |
-
#
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
6 |
# Configuración de la página principal
|
7 |
st.set_page_config(page_title="Customer Insights App", page_icon=":bar_chart:")
|
8 |
|
9 |
+
# Cargar el archivo CSV que ya está disponible en la web
|
10 |
+
# Asegúrate de que el archivo esté en el mismo directorio o en una ubicación accesible
|
11 |
+
df = pd.read_csv("ruta_del_archivo.csv") # Actualiza "ruta_del_archivo.csv" con la ruta correcta
|
12 |
+
|
13 |
# Diseño de la página principal
|
14 |
st.title("Welcome to Customer Insights App")
|
15 |
st.markdown("""
|
|
|
32 |
Use the tools below to explore your customer data.
|
33 |
""")
|
34 |
|
35 |
+
# Input para código de cliente
|
36 |
+
customer_code = st.text_input("Enter Customer Code")
|
37 |
+
|
38 |
+
if customer_code:
|
39 |
+
# Filtrar datos para el cliente seleccionado
|
40 |
+
customer_data = df[df["CLIENTE"] == customer_code]
|
41 |
+
|
42 |
+
if not customer_data.empty:
|
43 |
+
st.write(f"### Analysis for Customer {customer_code}")
|
44 |
+
|
45 |
+
# Generar un gráfico spider (radar chart)
|
46 |
+
categories = ['Variable1', 'Variable2', 'Variable3', 'Variable4'] # Aquí puedes incluir tus variables específicas
|
47 |
+
customer_values = [customer_data[category].values[0] for category in categories]
|
48 |
+
|
49 |
+
fig_spider = go.Figure()
|
50 |
+
fig_spider.add_trace(go.Scatterpolar(
|
51 |
+
r=customer_values,
|
52 |
+
theta=categories,
|
53 |
+
fill='toself',
|
54 |
+
name=f'Customer {customer_code}'
|
55 |
+
))
|
56 |
+
fig_spider.update_layout(
|
57 |
+
polar=dict(
|
58 |
+
radialaxis=dict(
|
59 |
+
visible=True,
|
60 |
+
range=[0, max(customer_values) + 1]
|
61 |
+
)),
|
62 |
+
showlegend=False,
|
63 |
+
title=f'Spider Chart for Customer {customer_code}'
|
64 |
+
)
|
65 |
+
st.plotly_chart(fig_spider)
|
66 |
+
|
67 |
+
# Ventas del cliente 2021-2024
|
68 |
+
years = ['2021', '2022', '2023', '2024']
|
69 |
+
sales_columns = ['VENTA_2021', 'VENTA_2022', 'VENTA_2023', 'VENTA_2024'] # Nombres de las columnas para ventas por año
|
70 |
+
customer_sales = [customer_data[col].values[0] for col in sales_columns]
|
71 |
+
|
72 |
+
fig_sales = px.line(x=years, y=customer_sales, markers=True, title=f'Sales Over the Years for Customer {customer_code}')
|
73 |
+
fig_sales.update_layout(xaxis_title="Year", yaxis_title="Sales")
|
74 |
+
st.plotly_chart(fig_sales)
|
75 |
+
|
76 |
+
else:
|
77 |
+
st.warning(f"No data found for customer {customer_code}. Please check the code.")
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# Página Customer Recommendations
|
80 |
elif page == "Customer Recommendations":
|
|
|
83 |
Get tailored recommendations for your customers based on their purchasing history.
|
84 |
""")
|
85 |
|
86 |
+
# Input para código de cliente
|
87 |
+
customer_code = st.text_input("Enter Customer Code for Recommendations")
|
88 |
+
|
89 |
+
if customer_code:
|
90 |
+
customer_data = df[df["CLIENTE"] == customer_code]
|
91 |
+
|
92 |
+
if not customer_data.empty:
|
93 |
+
# Mostrar historial de compras del cliente seleccionado
|
94 |
+
st.write(f"### Purchase History for Customer {customer_code}")
|
95 |
+
st.write(customer_data)
|
96 |
+
|
97 |
+
# Generar recomendaciones (placeholder)
|
98 |
+
st.write(f"### Recommended Products for Customer {customer_code}")
|
99 |
+
# Aquí puedes reemplazar con la lógica del modelo de recomendación
|
100 |
+
st.write("Product A, Product B, Product C")
|
101 |
+
else:
|
102 |
+
st.warning(f"No data found for customer {customer_code}. Please check the code.")
|