Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
d0f6704
1
Parent(s):
f637681
feat: generated files
Browse files
app.py
CHANGED
@@ -12,6 +12,9 @@ df = pd.read_csv("df_clean.csv") # Asegúrate de que la ruta del archivo es cor
|
|
12 |
# Ignorar las dos últimas columnas
|
13 |
df = df.iloc[:, :-2]
|
14 |
|
|
|
|
|
|
|
15 |
# Diseño de la página principal
|
16 |
st.title("Welcome to Customer Insights App")
|
17 |
st.markdown("""
|
@@ -34,12 +37,24 @@ elif page == "Customer Analysis":
|
|
34 |
Use the tools below to explore your customer data.
|
35 |
""")
|
36 |
|
37 |
-
#
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
if customer_code:
|
41 |
# Filtrar datos para el cliente seleccionado
|
42 |
-
customer_data = df[df
|
43 |
|
44 |
if not customer_data.empty:
|
45 |
st.write(f"### Analysis for Customer {customer_code}")
|
@@ -87,11 +102,23 @@ elif page == "Customer Recommendations":
|
|
87 |
Get tailored recommendations for your customers based on their purchasing history.
|
88 |
""")
|
89 |
|
90 |
-
#
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
if customer_code:
|
94 |
-
customer_data = df[df
|
95 |
|
96 |
if not customer_data.empty:
|
97 |
# Mostrar historial de compras del cliente seleccionado
|
|
|
12 |
# Ignorar las dos últimas columnas
|
13 |
df = df.iloc[:, :-2]
|
14 |
|
15 |
+
# Asegurarse de que el código del cliente sea una cadena (string)
|
16 |
+
df['CLIENTE'] = df['CLIENTE'].astype(str)
|
17 |
+
|
18 |
# Diseño de la página principal
|
19 |
st.title("Welcome to Customer Insights App")
|
20 |
st.markdown("""
|
|
|
37 |
Use the tools below to explore your customer data.
|
38 |
""")
|
39 |
|
40 |
+
# Campo para filtrar clientes
|
41 |
+
partial_code = st.text_input("Enter part of Customer Code (or leave empty to see all)")
|
42 |
+
|
43 |
+
# Filtrar las opciones de clientes que coincidan con el código parcial
|
44 |
+
if partial_code:
|
45 |
+
filtered_customers = df[df['CLIENTE'].str.contains(partial_code)]
|
46 |
+
else:
|
47 |
+
filtered_customers = df
|
48 |
+
|
49 |
+
# Crear una lista de clientes filtrados para el selectbox
|
50 |
+
customer_list = filtered_customers['CLIENTE'].unique()
|
51 |
+
|
52 |
+
# Selección de cliente con autocompletar filtrado
|
53 |
+
customer_code = st.selectbox("Select Customer Code", customer_list)
|
54 |
|
55 |
if customer_code:
|
56 |
# Filtrar datos para el cliente seleccionado
|
57 |
+
customer_data = df[df["CLIENTE"] == customer_code]
|
58 |
|
59 |
if not customer_data.empty:
|
60 |
st.write(f"### Analysis for Customer {customer_code}")
|
|
|
102 |
Get tailored recommendations for your customers based on their purchasing history.
|
103 |
""")
|
104 |
|
105 |
+
# Campo para filtrar clientes
|
106 |
+
partial_code = st.text_input("Enter part of Customer Code for Recommendations (or leave empty to see all)")
|
107 |
+
|
108 |
+
# Filtrar las opciones de clientes que coincidan con el código parcial
|
109 |
+
if partial_code:
|
110 |
+
filtered_customers = df[df['CLIENTE'].str.contains(partial_code)]
|
111 |
+
else:
|
112 |
+
filtered_customers = df
|
113 |
+
|
114 |
+
# Crear una lista de clientes filtrados para el selectbox
|
115 |
+
customer_list = filtered_customers['CLIENTE'].unique()
|
116 |
+
|
117 |
+
# Selección de cliente con autocompletar filtrado
|
118 |
+
customer_code = st.selectbox("Select Customer Code for Recommendations", customer_list)
|
119 |
|
120 |
if customer_code:
|
121 |
+
customer_data = df[df["CLIENTE"] == customer_code]
|
122 |
|
123 |
if not customer_data.empty:
|
124 |
# Mostrar historial de compras del cliente seleccionado
|