Spaces:
Sleeping
Sleeping
perezcatriel
commited on
Commit
•
cfc6bc9
1
Parent(s):
d1c7334
primer commit
Browse files- boxplot_clientes.py +48 -0
- data/po_excel_original.csv +25 -0
- main.py +30 -0
- top_5_clientes.py +52 -0
- ventas_anuales_clientes.py +29 -0
boxplot_clientes.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import plotly.express as px
|
3 |
+
import plotly.graph_objects as go
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
+
# Carga del archivo CSV
|
7 |
+
df = pd.read_csv('data/po_excel_original.csv')
|
8 |
+
|
9 |
+
def boxplot():
|
10 |
+
# Subtítulo: Boxplot de Clientes
|
11 |
+
st.subheader("Boxplot de Clientes")
|
12 |
+
|
13 |
+
# Crear un boxplot de las ventas por cliente
|
14 |
+
fig = go.Figure()
|
15 |
+
|
16 |
+
# Agregar los boxplots
|
17 |
+
fig.add_trace(go.Box(y=df["Total"], name="Boxplot"))
|
18 |
+
|
19 |
+
# Configurar el posicionamiento de los nombres de los clientes
|
20 |
+
pos_x = [len(df) + 2] * len(df)
|
21 |
+
|
22 |
+
# Agregar los puntos de los clientes y sus nombres a la leyenda
|
23 |
+
for i, cliente in enumerate(df["Clientes"]):
|
24 |
+
fig.add_trace(go.Scatter(x=pos_x, y=[df.loc[i, "Total"]],
|
25 |
+
mode='markers',
|
26 |
+
name=cliente,
|
27 |
+
marker=dict(color='green', size=12,
|
28 |
+
symbol='circle'),
|
29 |
+
visible='legendonly'))
|
30 |
+
|
31 |
+
# Configurar el diseño del boxplot y el tamaño de la figura
|
32 |
+
fig.update_layout(
|
33 |
+
yaxis=dict(title="Ventas"),
|
34 |
+
boxmode='group',
|
35 |
+
autosize=True,
|
36 |
+
width=900,
|
37 |
+
height=600,
|
38 |
+
legend=dict(
|
39 |
+
x=1.1,
|
40 |
+
y=0.5,
|
41 |
+
bgcolor='rgba(255, 255, 255, 0.5)',
|
42 |
+
bordercolor='rgba(0, 0, 0, 0.3)',
|
43 |
+
borderwidth=1
|
44 |
+
)
|
45 |
+
)
|
46 |
+
|
47 |
+
# Mostrar el boxplot con los nombres de los clientes
|
48 |
+
st.plotly_chart(fig, use_container_width=True)
|
data/po_excel_original.csv
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,Clientes,Ene,Feb,Mar,Abr,May,Jun,Jul,Ago,Sep,Oct,Nov,Dic,Total,cantidad,Nada,Cant,Promedio,Porcentaje,Proyeccion,Ch,Gr,An,Fu,Visitar_cada,Año,Contrato,Documento,Cobrador,Repositor,Direccion,Localidad,Provincia,Zona,Telefono,Oficial,CUIT,Detalles,F.u.reposicion,M.u.reposicion,saldo,F.p.reposicion,Libro,Columna1,Columna2
|
2 |
+
0,Aeroclub,5544,0,0,1,0,0,0,0,0,0,0,0,5545,1,,0,462,,0,0,0,0,0,#REF!,0,='F_Aeroclub'!L19,='F_Aeroclub'!L20,0,12-30-99,#REF!,#REF!,#REF!,0,#REF!,0.0,='Aeroclub'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,14-1-00,0
|
3 |
+
1,Campus Olegario,5544,1,7500,7428,7142,0,0,0,0,0,0,0,27615,4,,0,2301,,0,0,0,0,0,#REF!,0,='F_Campus Olegario'!L19,='F_Campus Olegario'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Campus Olegario'!L2,#REF!,30-12-99,15.0,0,#REF!,P.O.,30-12-99,0
|
4 |
+
2,Carnes Kiosco Martorell,5544,0,5001,0,0,0,0,0,0,0,0,0,10545,2,,0,878,,0,0,0,0,0,#REF!,0,='F_Carnes Kiosco Martorell'!L19,='F_Carnes Kiosco Martorell'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Carnes Kiosco Martorell'!L2,#REF!,14-1-00,0.0,0,#REF!,P.O.,Chico,0
|
5 |
+
3,Carnes Martorell Maipú,5544,6857,23142,6500,0,0,0,0,0,0,0,0,42043,4,,0,3503,,0,0,0,0,0,#REF!,0,='F_Carnes Martorell Maipú'!L19,='F_Carnes Martorell Maipú'!L20,15,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Carnes Martorell Maipú'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
6 |
+
4,Carnes Mortorell Quinta,5544,3857,0,7285,0,0,0,0,0,0,0,0,16686,3,,0,1390,,0,0,0,0,0,#REF!,0,='F_Carnes Mortorell Quinta'!L19,='F_Carnes Mortorell Quinta'!L20,0,1.14.1900,#REF!,#REF!,#REF!,0,#REF!,0.0,='Carnes Mortorell Quinta'!L2,#REF!,Chico,0.0,0,#VALUE!,P.O.,30-12-99,0
|
7 |
+
5,Copy Rap,5544,1,15000,19428,0,0,0,0,0,0,0,0,39973,3,,0,3331,,0,0,0,0,0,#REF!,0,='F_Copy Rap'!L19,='F_Copy Rap'!L20,Chico,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Copy Rap'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
8 |
+
6,Kiosco El Resplandor,5544,0,0,0,4001,0,0,0,0,0,0,0,9545,2,,0,795,,0,0,0,0,0,#REF!,0,='F_Kiosco El Resplandor'!L19,='F_Kiosco El Resplandor'!L20,0,Chico,#REF!,#REF!,#REF!,0,#REF!,0.0,='Kiosco El Resplandor'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
9 |
+
7,Los Abuelos,5544,0,6428,0,0,0,0,0,0,0,0,3429,15401,3,,0,1283,,0,0,0,0,0,#REF!,0,='F_Los Abuelos'!L19,='F_Los Abuelos'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Los Abuelos'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
10 |
+
8,Mario,5544,5142,3464,0,0,0,0,0,0,0,0,1,14151,3,,0,1179,,0,0,0,0,0,#REF!,0,='F_Mario'!L19,='F_Mario'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Mario'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
11 |
+
9,Mini 210,5544,0,1,2571,0,0,0,0,0,0,0,0,8116,2,,0,676,,0,0,0,0,0,#REF!,0,='F_Mini 210'!L19,='F_Mini 210'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Mini 210'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
12 |
+
10,Minimarket Olegario,5544,0,1,6571,0,0,0,0,0,0,0,0,12116,2,,0,1009,,0,0,0,0,0,#REF!,0,='F_Minimarket Olegario'!L19,='F_Minimarket Olegario'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Minimarket Olegario'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,20
|
13 |
+
11,Parador Belgrano,5544,5000,6800,4857,8857,0,0,0,0,0,0,0,31058,5,,0,2588,,0,0,0,0,0,#REF!,0,='F_Parador Belgrano'!L19,='F_Parador Belgrano'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Parador Belgrano'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,19-1-00,28269
|
14 |
+
12,Pedidos Ya,5544,0,0,0,0,0,0,0,0,0,14151,25747,45442,3,,0,3786,,0,0,0,0,0,#REF!,0,='F_Pedidos Ya'!L19,='F_Pedidos Ya'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Pedidos Ya'!L2,#REF!,30-12-99,20.0,0,#REF!,P.O.,24-5-77,2022
|
15 |
+
13,Photoshop,5544,1,9750,0,0,0,0,0,0,0,0,0,15295,2,,0,1274,,0,0,0,0,0,#REF!,0,='F_Photoshop'!L19,='F_Photoshop'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Photoshop'!L2,#REF!,19-1-00,28269.23,0,#REF!,P.O.,14-7-05,0
|
16 |
+
14,Pileta Regatas,5544,1,7500,7714,0,0,0,0,0,0,0,0,20759,3,,0,1729,,0,0,0,0,0,#REF!,0,='F_Pileta Regatas'!L19,='F_Pileta Regatas'!L20,20,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Pileta Regatas'!L2,#REF!,24-5-77,2022.0,0,#REF!,P.O.,30-12-99,0
|
17 |
+
15,Tienda On Line,5544,23600,0,0,0,0,0,0,0,0,0,0,29144,2,,0,2428,,0,0,0,0,0,#REF!,0,='F_Tienda On Line'!L19,='F_Tienda On Line'!L20,28269.230769230766,1.19.1900,#REF!,#REF!,#REF!,0,#REF!,0.0,='Tienda On Line'!L2,#REF!,14-7-05,0.0,0,#REF!,P.O.,30-12-99,0
|
18 |
+
16,X,5544,0,0,0,0,0,0,0,0,1,0,0,5545,1,,0,462,,0,0,0,0,0,#REF!,0,='F_X'!L19,='F_X'!L20,2022,5.24.1977,#REF!,#REF!,#REF!,0,#REF!,0.0,='X'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
19 |
+
17,YPF Atencio,5544,0,0,4281,0,0,0,0,0,0,0,0,9825,2,,0,818,,0,0,0,0,0,#REF!,0,='F_YPF Atencio'!L19,='F_YPF Atencio'!L20,0,7.14.1905,#REF!,#REF!,#REF!,0,#REF!,0.0,='YPF Atencio'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
20 |
+
18,Ashtanga Ceci,5544,0,3928,0,2464,0,0,0,0,1,3142,0,15079,4,,0,1256,,0,0,0,0,0,#REF!,0,='F_Ashtanga Ceci'!L19,='F_Ashtanga Ceci'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Ashtanga Ceci'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,30-12-99,0
|
21 |
+
19,CARN ANGUS,5544,6000,0,7285,0,0,0,0,0,0,3429,0,22258,4,,0,1854,,0,0,0,0,0,#REF!,0,='F_CARN ANGUS'!L19,='F_CARN ANGUS'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='CARN ANGUS'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,Ruth,0
|
22 |
+
20,Ignacia store,5544,0,0,8000,0,0,0,0,0,0,2572,0,16116,3,,0,1343,,0,0,0,0,0,#REF!,0,='F_Ignacia store'!L19,='F_Ignacia store'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Ignacia store'!L2,#REF!,30-12-99,0.0,0,#REF!,P.O.,Ruth,45042
|
23 |
+
21,Dza Municipal,5544,0,0,0,0,0,0,0,0,1,1428,0,6973,2,,0,581,,0,0,0,0,0,#REF!,0,='F_Dza Municipal'!L19,='F_Dza Municipal'!L20,0,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='Dza Municipal'!L2,#REF!,Ruth,0.0,0,#VALUE!,P.O.,26-4-23,13692
|
24 |
+
22,La alfombra mágica,5544,6428,5571,12500,0,0,0,0,0,1,6570,0,36614,5,,0,3051,,0,0,0,0,0,#REF!,0,='F_La alfombra mágica'!L19,='F_La alfombra mágica'!L20,Ruth,12.30.1899,#REF!,#REF!,#REF!,0,#REF!,0.0,='La alfombra mágica'!L2,#REF!,Ruth,45042.0,0,#VALUE!,P.O.,26-6-37,0
|
25 |
+
23,Super H,5544,0,4615,13692,0,0,0,0,0,3077,6691,0,33619,5,,0,2801,,0,0,0,0,0,#REF!,0,='F_Super H'!L19,='F_Super H'!L20,Ruth,Ruth,#REF!,#REF!,#REF!,0,#REF!,0.0,='Super H'!L2,#REF!,26-4-23,13692.0,0,#REF!,P.O.,30-12-99,0
|
main.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Importación de las bibliotecas necesarias
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
import pandas as pd
|
5 |
+
import streamlit as st
|
6 |
+
|
7 |
+
from boxplot_clientes import boxplot
|
8 |
+
from top_5_clientes import top_5
|
9 |
+
from ventas_anuales_clientes import ventas_anuales
|
10 |
+
|
11 |
+
# Carga del archivo CSV
|
12 |
+
df = pd.read_csv('data/po_excel_original.csv')
|
13 |
+
|
14 |
+
# Seleccionar top clientes por ventas
|
15 |
+
top_clientes = df.groupby("Clientes")["Total"].sum().sort_values(
|
16 |
+
ascending=False)
|
17 |
+
|
18 |
+
# Título de la aplicación Streamlit
|
19 |
+
st.title("Análisis de Clientes y Ventas de Punto Orgánico")
|
20 |
+
|
21 |
+
|
22 |
+
def run():
|
23 |
+
# subprocess.run(["streamlit", "run", "main.py"])
|
24 |
+
ventas_anuales()
|
25 |
+
boxplot()
|
26 |
+
top_5()
|
27 |
+
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
run()
|
top_5_clientes.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Carga del archivo CSV
|
6 |
+
df = pd.read_csv('data/po_excel_original.csv')
|
7 |
+
|
8 |
+
def top_5():
|
9 |
+
# Ordenar el DataFrame por el total de forma descendente
|
10 |
+
df_sorted = df.sort_values("Total", ascending=False)
|
11 |
+
|
12 |
+
# Título para los filtros laterales
|
13 |
+
st.sidebar.title("Filtros Ventas Anuales TOP clientes")
|
14 |
+
|
15 |
+
# Crear los controles interactivos para los filtros en la barra lateral
|
16 |
+
filtro_x = st.sidebar.slider("Monto mínimo de compras", min_value=0, max_value=int(df_sorted["Total"].max()),
|
17 |
+
value=100, step=1)
|
18 |
+
|
19 |
+
# Aplicar los filtros al DataFrame
|
20 |
+
df_filtrado = df_sorted[df_sorted["Total"] >= filtro_x]
|
21 |
+
|
22 |
+
# Control para la cantidad de clientes a mostrar
|
23 |
+
filtro_n = st.sidebar.slider("Cantidad de clientes a mostrar", min_value=1,
|
24 |
+
max_value=len(df_filtrado), value=10)
|
25 |
+
|
26 |
+
# Aplicar el segundo filtro al DataFrame
|
27 |
+
df_filtrado = df_filtrado.head(filtro_n)
|
28 |
+
|
29 |
+
# Titulo del Grafico
|
30 |
+
st.subheader("Ventas Anuales por TOP de clientes")
|
31 |
+
|
32 |
+
# Crear el gráfico interactivo con Plotly
|
33 |
+
fig = px.bar(df_filtrado, x="Total", y="Clientes", color="Total",
|
34 |
+
log_x=True, color_continuous_scale="greens") # Modificar la paleta de colores
|
35 |
+
|
36 |
+
# Personalizar el diseño del gráfico
|
37 |
+
fig.update_layout(
|
38 |
+
xaxis=dict(categoryorder="total descending"),
|
39 |
+
yaxis={'categoryorder':'total ascending'},
|
40 |
+
showlegend=False
|
41 |
+
)
|
42 |
+
|
43 |
+
# Configurar el tamaño del gráfico para que se muestren todos los nombres
|
44 |
+
fig.update_layout(
|
45 |
+
autosize=True,
|
46 |
+
width=800,
|
47 |
+
height=500
|
48 |
+
)
|
49 |
+
|
50 |
+
# Mostrar el gráfico en Streamlit
|
51 |
+
st.plotly_chart(fig)
|
52 |
+
|
ventas_anuales_clientes.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import plotly.express as px
|
3 |
+
import streamlit as st
|
4 |
+
from datetime import date
|
5 |
+
|
6 |
+
def ventas_anuales():
|
7 |
+
# Carga del archivo CSV
|
8 |
+
df = pd.read_csv('data/po_excel_original.csv')
|
9 |
+
|
10 |
+
# Transforma las columnas de meses en filas
|
11 |
+
df = df.melt(id_vars='Año', var_name='Mes', value_name='Ventas')
|
12 |
+
|
13 |
+
# Reordena los meses en orden cronológico
|
14 |
+
meses_ordenados = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago',
|
15 |
+
'Sep', 'Oct', 'Nov', 'Dic']
|
16 |
+
df['Mes'] = pd.Categorical(df['Mes'], categories=meses_ordenados, ordered=True)
|
17 |
+
|
18 |
+
# Ordena el DataFrame por año y mes
|
19 |
+
df = df.sort_values(['Año', 'Mes'])
|
20 |
+
|
21 |
+
# Filtra los datos hasta el último mes mostrado
|
22 |
+
ultimo_mes_mostrado = meses_ordenados[date.today().month-1]
|
23 |
+
df = df[df['Mes'] <= ultimo_mes_mostrado]
|
24 |
+
|
25 |
+
# Crea el gráfico de barras
|
26 |
+
fig = px.bar(df, x='Mes', y='Ventas', color='Año', title='Ventas Anuales', labels={'Ventas': 'Ventas ($)', 'Mes': 'Mes', 'Año': 'Año'})
|
27 |
+
|
28 |
+
# Muestra el gráfico en Streamlit
|
29 |
+
st.plotly_chart(fig, use_container_width=True)
|