Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
f0e70c5
1
Parent(s):
afc712c
feat: generated files
Browse files
app.py
CHANGED
@@ -125,8 +125,8 @@ elif page == "Customer Analysis":
|
|
125 |
# Get all manufacturers the customer bought from (ignore the customer column)
|
126 |
all_manufacturers = customer_data.iloc[:, 1:].T[customer_data.iloc[:, 1:].T[customer_data.index[0]] > purchase_threshold]
|
127 |
|
128 |
-
# Sort manufacturers by value in descending order
|
129 |
-
all_manufacturers = all_manufacturers.sort_values(by=customer_data.index[0], ascending=False)
|
130 |
|
131 |
# Prepare values and manufacturers
|
132 |
values = all_manufacturers[customer_data.index[0]].values.tolist()
|
@@ -140,19 +140,13 @@ elif page == "Customer Analysis":
|
|
140 |
else:
|
141 |
amounts.append(0)
|
142 |
|
143 |
-
# If there are fewer than 3 manufacturers, add a third one with value 0
|
144 |
-
if len(manufacturers) < 3:
|
145 |
-
manufacturers.append("Other")
|
146 |
-
values.append(0)
|
147 |
-
amounts.append(0)
|
148 |
-
|
149 |
# Display the results for each manufacturer
|
150 |
-
st.write(f"### Results for {len(manufacturers)} manufacturers (sorted):")
|
151 |
for manufacturer, value, amount in zip(manufacturers, values, amounts):
|
152 |
st.write(f"{manufacturer} = {value:.4f} units, €{amount:.2f}")
|
153 |
|
154 |
# Create and display the radar chart
|
155 |
-
fig = radar_chart(manufacturers, values, amounts, f'Radar Chart for {len(manufacturers)} Manufacturers of Customer {customer_code}')
|
156 |
st.pyplot(fig)
|
157 |
|
158 |
# Customer sales 2021-2024 (if data exists)
|
|
|
125 |
# Get all manufacturers the customer bought from (ignore the customer column)
|
126 |
all_manufacturers = customer_data.iloc[:, 1:].T[customer_data.iloc[:, 1:].T[customer_data.index[0]] > purchase_threshold]
|
127 |
|
128 |
+
# Sort manufacturers by value in descending order and limit to top 20
|
129 |
+
all_manufacturers = all_manufacturers.sort_values(by=customer_data.index[0], ascending=False).head(20)
|
130 |
|
131 |
# Prepare values and manufacturers
|
132 |
values = all_manufacturers[customer_data.index[0]].values.tolist()
|
|
|
140 |
else:
|
141 |
amounts.append(0)
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
# Display the results for each manufacturer
|
144 |
+
st.write(f"### Results for top {len(manufacturers)} manufacturers (sorted):")
|
145 |
for manufacturer, value, amount in zip(manufacturers, values, amounts):
|
146 |
st.write(f"{manufacturer} = {value:.4f} units, €{amount:.2f}")
|
147 |
|
148 |
# Create and display the radar chart
|
149 |
+
fig = radar_chart(manufacturers, values, amounts, f'Radar Chart for Top {len(manufacturers)} Manufacturers of Customer {customer_code}')
|
150 |
st.pyplot(fig)
|
151 |
|
152 |
# Customer sales 2021-2024 (if data exists)
|