Spaces:
Sleeping
Sleeping
Commit
·
5eb4c6b
1
Parent(s):
04f10a7
feat: generated files
Browse files
app.py
CHANGED
@@ -104,8 +104,20 @@ elif page == "Customer Analysis":
|
|
104 |
|
105 |
all_manufacturers = customer_data.iloc[:, 1:].T[customer_data.iloc[:, 1:].T[customer_data.index[0]] > 0]
|
106 |
|
|
|
|
|
|
|
|
|
107 |
top_units = all_manufacturers.sort_values(by=customer_data.index[0], ascending=False).head(10)
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
combined_top = pd.concat([top_units, top_sales]).index.unique()
|
110 |
|
111 |
values = []
|
@@ -122,8 +134,11 @@ elif page == "Customer Analysis":
|
|
122 |
for manufacturer, value, amount in zip(manufacturers, values, amounts):
|
123 |
st.write(f"{manufacturer} = {value:.4f} units, €{amount:.2f}")
|
124 |
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
127 |
|
128 |
# Customer sales 2021-2024 (if data exists)
|
129 |
if 'VENTA_2021' in df.columns and 'VENTA_2022' in df.columns and 'VENTA_2023' in df.columns and 'VENTA_2024' in df.columns:
|
|
|
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')
|
109 |
+
customer_euros = customer_euros.apply(pd.to_numeric, errors='coerce')
|
110 |
+
|
111 |
top_units = all_manufacturers.sort_values(by=customer_data.index[0], ascending=False).head(10)
|
112 |
+
|
113 |
+
# Ensure we're working with numeric data for sorting
|
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()
|
120 |
+
|
121 |
combined_top = pd.concat([top_units, top_sales]).index.unique()
|
122 |
|
123 |
values = []
|
|
|
134 |
for manufacturer, value, amount in zip(manufacturers, values, amounts):
|
135 |
st.write(f"{manufacturer} = {value:.4f} units, €{amount:.2f}")
|
136 |
|
137 |
+
if manufacturers: # Only create the chart if we have data
|
138 |
+
fig = radar_chart(manufacturers, values, amounts, f'Radar Chart for Top {len(manufacturers)} Manufacturers of Customer {customer_code}')
|
139 |
+
st.pyplot(fig)
|
140 |
+
else:
|
141 |
+
st.warning("No data available to create the radar chart.")
|
142 |
|
143 |
# Customer sales 2021-2024 (if data exists)
|
144 |
if 'VENTA_2021' in df.columns and 'VENTA_2022' in df.columns and 'VENTA_2023' in df.columns and 'VENTA_2024' in df.columns:
|