Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
import plotly.express as px | |
# Configuración de la página principal | |
st.set_page_config(page_title="Customer Insights App", page_icon=":bar_chart:") | |
# Diseño de la página principal | |
st.title("Welcome to Customer Insights App") | |
st.markdown(""" | |
This app helps businesses analyze customer behaviors and provide personalized recommendations based on purchase history. | |
Use the tools below to dive deeper into your customer data. | |
""") | |
# Menú de navegación | |
page = st.selectbox("Select a page", ["Home", "Customer Analysis", "Customer Recommendations"]) | |
# Página Home | |
if page == "Home": | |
st.markdown("## Welcome to the Customer Insights App") | |
st.write("Use the dropdown menu to navigate between the different sections.") | |
# Página Customer Analysis | |
elif page == "Customer Analysis": | |
st.title("Customer Analysis") | |
st.markdown(""" | |
Use the tools below to explore your customer data. | |
""") | |
# Cargar y visualizar datos | |
uploaded_file = st.file_uploader("Upload your CSV file", type="csv") | |
if uploaded_file: | |
df = pd.read_csv(uploaded_file) | |
st.write("## Dataset Overview", df.head()) | |
# Mostrar un gráfico interactivo | |
st.markdown("### Sales per Customer") | |
customer_sales = df.groupby("CLIENTE")["VENTA_ANUAL"].sum().reset_index() | |
fig = px.bar(customer_sales, x="CLIENTE", y="VENTA_ANUAL", title="Annual Sales per Customer") | |
st.plotly_chart(fig) | |
# Página Customer Recommendations | |
elif page == "Customer Recommendations": | |
st.title("Customer Recommendations") | |
st.markdown(""" | |
Get tailored recommendations for your customers based on their purchasing history. | |
""") | |
# Cargar los datos | |
uploaded_file = st.file_uploader("Upload your CSV file", type="csv") | |
if uploaded_file: | |
df = pd.read_csv(uploaded_file) | |
# Selección de cliente | |
customer_id = st.selectbox("Select a Customer", df["CLIENTE"].unique()) | |
# Mostrar historial de compras del cliente seleccionado | |
st.write(f"### Purchase History for Customer {customer_id}") | |
customer_data = df[df["CLIENTE"] == customer_id] | |
st.write(customer_data) | |
# Generar recomendaciones (placeholder) | |
st.write(f"### Recommended Products for Customer {customer_id}") | |
# Aquí puedes reemplazar con tu lógica de recomendación de productos | |
st.write("Product A, Product B, Product C") | |