Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
·
0e7425f
1
Parent(s):
4049276
feat: updated website
Browse files
app.py
CHANGED
@@ -109,26 +109,29 @@ def get_supplier_name(code):
|
|
109 |
return name[0] if len(name) > 0 else code
|
110 |
|
111 |
def get_supplier_name_encoded(encoded_code):
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
real_code = marca_id_mapping.inverse_transform([encoded_code])[0]
|
117 |
-
else:
|
118 |
-
return f"Unknown code: {encoded_code}" # Handle case where encoded code is not found
|
119 |
-
|
120 |
-
def get_supplier_name_encoded(encoded_code):
|
121 |
-
encoded_code = int(encoded_code) # Ensure the encoded code is an integer
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
else:
|
127 |
-
return f"Unknown code: {encoded_code}" # Handle case where encoded code is not found
|
128 |
-
|
129 |
-
# Now, use the real_code to find the manufacturer name in nombres_proveedores
|
130 |
-
name = nombres_proveedores[nombres_proveedores['codigo'] == str(real_code)]['nombre'].values
|
131 |
-
return name[0] if len(name) > 0 else real_code
|
132 |
|
133 |
# Custom Donut Chart with Plotly for Inbound/Outbound Percentage
|
134 |
def create_donut_chart(values, labels, color_scheme, title):
|
|
|
109 |
return name[0] if len(name) > 0 else code
|
110 |
|
111 |
def get_supplier_name_encoded(encoded_code):
|
112 |
+
try:
|
113 |
+
# Ensure the encoded code is an integer
|
114 |
+
encoded_code = int(encoded_code)
|
115 |
+
print(f"Encoded Code: {encoded_code}")
|
116 |
+
|
117 |
+
# Check if the encoded code exists in the label encoder
|
118 |
+
if encoded_code in marca_id_mapping.classes_:
|
119 |
+
real_code = marca_id_mapping.inverse_transform([encoded_code])[0]
|
120 |
+
print(f"Real Manufacturer Code: {real_code}")
|
121 |
+
else:
|
122 |
+
print(f"Encoded code not found in the label encoder: {encoded_code}")
|
123 |
+
return f"Unknown code: {encoded_code}" # Handle case where encoded code is not found
|
124 |
+
|
125 |
+
# Now, look up the real manufacturer code in the nombres_proveedores DataFrame
|
126 |
+
name = nombres_proveedores[nombres_proveedores['codigo'] == str(real_code)]['nombre'].values
|
127 |
+
print(f"Manufacturer Name Found: {name}") # Check what name is returned
|
128 |
|
129 |
+
# Return the manufacturer name if found, otherwise return the real_code
|
130 |
+
return name[0] if len(name) > 0 else real_code
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
except Exception as e:
|
133 |
+
print(f"Error encountered: {e}")
|
134 |
+
return f"Error for code: {encoded_code}"
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
# Custom Donut Chart with Plotly for Inbound/Outbound Percentage
|
137 |
def create_donut_chart(values, labels, color_scheme, title):
|