Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
d496756
1
Parent(s):
b6148e0
feat: generated files
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
|
|
4 |
|
5 |
# Configuración de la página principal
|
6 |
st.set_page_config(page_title="Customer Insights App", page_icon=":bar_chart:")
|
@@ -33,11 +34,49 @@ elif page == "Customer Analysis":
|
|
33 |
df = pd.read_csv(uploaded_file)
|
34 |
st.write("## Dataset Overview", df.head())
|
35 |
|
36 |
-
#
|
37 |
-
st.
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# Página Customer Recommendations
|
43 |
elif page == "Customer Recommendations":
|
@@ -61,5 +100,5 @@ elif page == "Customer Recommendations":
|
|
61 |
|
62 |
# Generar recomendaciones (placeholder)
|
63 |
st.write(f"### Recommended Products for Customer {customer_id}")
|
64 |
-
# Aquí puedes reemplazar con
|
65 |
st.write("Product A, Product B, Product C")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
+
import plotly.graph_objects as go
|
5 |
|
6 |
# Configuración de la página principal
|
7 |
st.set_page_config(page_title="Customer Insights App", page_icon=":bar_chart:")
|
|
|
34 |
df = pd.read_csv(uploaded_file)
|
35 |
st.write("## Dataset Overview", df.head())
|
36 |
|
37 |
+
# Input para código de cliente
|
38 |
+
customer_code = st.text_input("Enter Customer Code")
|
39 |
+
|
40 |
+
if customer_code:
|
41 |
+
# Filtrar datos para el cliente seleccionado
|
42 |
+
customer_data = df[df["CLIENTE"] == customer_code]
|
43 |
+
|
44 |
+
if not customer_data.empty:
|
45 |
+
st.write(f"### Analysis for Customer {customer_code}")
|
46 |
+
|
47 |
+
# Generar un gráfico spider (radar chart)
|
48 |
+
categories = ['Variable1', 'Variable2', 'Variable3', 'Variable4'] # Aquí puedes incluir tus variables específicas
|
49 |
+
customer_values = [customer_data[category].values[0] for category in categories]
|
50 |
+
|
51 |
+
fig_spider = go.Figure()
|
52 |
+
fig_spider.add_trace(go.Scatterpolar(
|
53 |
+
r=customer_values,
|
54 |
+
theta=categories,
|
55 |
+
fill='toself',
|
56 |
+
name=f'Customer {customer_code}'
|
57 |
+
))
|
58 |
+
fig_spider.update_layout(
|
59 |
+
polar=dict(
|
60 |
+
radialaxis=dict(
|
61 |
+
visible=True,
|
62 |
+
range=[0, max(customer_values) + 1]
|
63 |
+
)),
|
64 |
+
showlegend=False,
|
65 |
+
title=f'Spider Chart for Customer {customer_code}'
|
66 |
+
)
|
67 |
+
st.plotly_chart(fig_spider)
|
68 |
+
|
69 |
+
# Ventas del cliente 2021-2024
|
70 |
+
years = ['2021', '2022', '2023', '2024']
|
71 |
+
sales_columns = ['VENTA_2021', 'VENTA_2022', 'VENTA_2023', 'VENTA_2024'] # Nombres de las columnas para ventas por año
|
72 |
+
customer_sales = [customer_data[col].values[0] for col in sales_columns]
|
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":
|
|
|
100 |
|
101 |
# Generar recomendaciones (placeholder)
|
102 |
st.write(f"### Recommended Products for Customer {customer_id}")
|
103 |
+
# Aquí puedes reemplazar con la lógica del modelo de recomendación
|
104 |
st.write("Product A, Product B, Product C")
|