GMARTINEZMILLA commited on
Commit
c6a929c
·
1 Parent(s): 5eb4c6b

feat: generated files

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -82,7 +82,6 @@ if page == "":
82
  st.markdown("## Welcome to the Customer Insights App")
83
  st.write("Use the dropdown menu to navigate between the different sections.")
84
 
85
- # Customer Analysis Page
86
  elif page == "Customer Analysis":
87
  st.title("Customer Analysis")
88
  st.markdown("Use the tools below to explore your customer data.")
@@ -102,7 +101,9 @@ elif page == "Customer Analysis":
102
  if not customer_data.empty and not customer_euros.empty:
103
  st.write(f"### Analysis for Customer {customer_code}")
104
 
 
105
  all_manufacturers = customer_data.iloc[:, 1:].T[customer_data.iloc[:, 1:].T[customer_data.index[0]] > 0]
 
106
 
107
  # Convert to numeric and handle any non-numeric values
108
  all_manufacturers = all_manufacturers.apply(pd.to_numeric, errors='coerce')
@@ -114,6 +115,7 @@ elif page == "Customer Analysis":
114
  numeric_euros = customer_euros.select_dtypes(include=[np.number])
115
  if not numeric_euros.empty:
116
  top_sales = numeric_euros.iloc[0].sort_values(ascending=False).head(10)
 
117
  else:
118
  st.warning("No numeric sales data available for this customer.")
119
  top_sales = pd.Series()
@@ -125,10 +127,10 @@ elif page == "Customer Analysis":
125
  amounts = []
126
 
127
  for m in combined_top:
128
- if m in all_manufacturers.index:
129
  values.append(all_manufacturers[m])
130
  manufacturers.append(get_supplier_name(m))
131
- amounts.append(customer_euros[m].values[0] if m in customer_euros.columns else 0)
132
 
133
  st.write(f"### Results for top {len(manufacturers)} manufacturers (balanced by units and sales):")
134
  for manufacturer, value, amount in zip(manufacturers, values, amounts):
 
82
  st.markdown("## Welcome to the Customer Insights App")
83
  st.write("Use the dropdown menu to navigate between the different sections.")
84
 
 
85
  elif page == "Customer Analysis":
86
  st.title("Customer Analysis")
87
  st.markdown("Use the tools below to explore your customer data.")
 
101
  if not customer_data.empty and not customer_euros.empty:
102
  st.write(f"### Analysis for Customer {customer_code}")
103
 
104
+ # Ensure all manufacturer codes are strings
105
  all_manufacturers = customer_data.iloc[:, 1:].T[customer_data.iloc[:, 1:].T[customer_data.index[0]] > 0]
106
+ all_manufacturers.index = all_manufacturers.index.astype(str)
107
 
108
  # Convert to numeric and handle any non-numeric values
109
  all_manufacturers = all_manufacturers.apply(pd.to_numeric, errors='coerce')
 
115
  numeric_euros = customer_euros.select_dtypes(include=[np.number])
116
  if not numeric_euros.empty:
117
  top_sales = numeric_euros.iloc[0].sort_values(ascending=False).head(10)
118
+ top_sales.index = top_sales.index.astype(str)
119
  else:
120
  st.warning("No numeric sales data available for this customer.")
121
  top_sales = pd.Series()
 
127
  amounts = []
128
 
129
  for m in combined_top:
130
+ if m in all_manufacturers.index and m in customer_euros.columns:
131
  values.append(all_manufacturers[m])
132
  manufacturers.append(get_supplier_name(m))
133
+ amounts.append(customer_euros[m].iloc[0])
134
 
135
  st.write(f"### Results for top {len(manufacturers)} manufacturers (balanced by units and sales):")
136
  for manufacturer, value, amount in zip(manufacturers, values, amounts):