Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -346,7 +346,61 @@ def report_view():
|
|
| 346 |
total_records = len(df)
|
| 347 |
|
| 348 |
df_page = df.iloc[start_idx:end_idx]
|
| 349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
has_prev = page > 1
|
| 352 |
has_next = end_idx < total_records
|
|
|
|
| 346 |
total_records = len(df)
|
| 347 |
|
| 348 |
df_page = df.iloc[start_idx:end_idx]
|
| 349 |
+
|
| 350 |
+
# # -------------------------------------V CHnages --------------------------------------
|
| 351 |
+
# # 👇 Inject arrows based on Makable_Diff
|
| 352 |
+
# def add_arrow(row):
|
| 353 |
+
# try:
|
| 354 |
+
# pred = float(row['Makable_Predicted'])
|
| 355 |
+
# diff = float(row['Makable_Diff'])
|
| 356 |
+
# if np.isnan(pred) or np.isnan(diff):
|
| 357 |
+
# return '-'
|
| 358 |
+
# arrow = '↑' if diff > 0 else '↓'
|
| 359 |
+
# return f"{pred:.3f} {arrow}"
|
| 360 |
+
# except:
|
| 361 |
+
# return row['Makable_Predicted']
|
| 362 |
+
|
| 363 |
+
# df_page['Makable_Predicted'] = df_page.apply(add_arrow, axis=1)
|
| 364 |
+
# # -------------------------------------V CHnages --------------------------------------
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
# -------------------------------------V Colored CHnages --------------------------------------
|
| 368 |
+
def add_colored_arrow(row):
|
| 369 |
+
try:
|
| 370 |
+
pred = float(row['Makable_Predicted'])
|
| 371 |
+
diff = float(row['Makable_Diff'])
|
| 372 |
+
if np.isnan(pred) or np.isnan(diff):
|
| 373 |
+
return '-'
|
| 374 |
+
if diff > 0:
|
| 375 |
+
return f'{pred:.3f} <span style="color:green;">↑</span>'
|
| 376 |
+
else:
|
| 377 |
+
return f'{pred:.3f} <span style="color:red;">↓</span>'
|
| 378 |
+
except:
|
| 379 |
+
return row['Makable_Predicted']
|
| 380 |
+
|
| 381 |
+
df_page['Makable_Predicted'] = df_page.apply(add_colored_arrow, axis=1)
|
| 382 |
+
# -------------------------------------V Colored CHnages --------------------------------------
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
# # -------------------------------------V Icon CHnages --------------------------------------
|
| 386 |
+
# def add_fa_icon(row):
|
| 387 |
+
# try:
|
| 388 |
+
# pred = float(row['Makable_Predicted'])
|
| 389 |
+
# diff = float(row['Makable_Diff'])
|
| 390 |
+
# if np.isnan(pred) or np.isnan(diff):
|
| 391 |
+
# return '-'
|
| 392 |
+
# if diff > 0:
|
| 393 |
+
# return f'{pred:.3f} <i class="fas fa-arrow-up" style="color:green;"></i>'
|
| 394 |
+
# else:
|
| 395 |
+
# return f'{pred:.3f} <i class="fas fa-arrow-down" style="color:red;"></i>'
|
| 396 |
+
# except:
|
| 397 |
+
# return row['Makable_Predicted']
|
| 398 |
+
|
| 399 |
+
# df_page['Makable_Predicted'] = df_page.apply(add_fa_icon, axis=1)
|
| 400 |
+
# # -------------------------------------V Icon CHnages --------------------------------------
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
table_html = df_page.to_html(classes="data-table", index=False, escape=False)
|
| 404 |
|
| 405 |
has_prev = page > 1
|
| 406 |
has_next = end_idx < total_records
|