Roni Goldshmidt
commited on
Commit
ยท
e55ea34
1
Parent(s):
f2dabfd
Initial leaderboard setup
Browse files- .ipynb_checkpoints/app-checkpoint.py +20 -13
- app.py +20 -13
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -567,28 +567,35 @@ with tab4:
|
|
567 |
|
568 |
# Display the styled table
|
569 |
|
570 |
-
|
571 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
return ''
|
573 |
-
color = 'green' if val > 0 else 'red' if val < 0 else 'black'
|
574 |
-
return f'color: {color}'
|
575 |
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
columns=data.columns
|
581 |
-
).iloc[0]
|
582 |
|
|
|
583 |
styled_df = metric_df.style\
|
584 |
-
.apply(highlight_last_column, axis=
|
585 |
-
.applymap(
|
586 |
.set_properties(**{'text-align': 'center'})\
|
587 |
.format(precision=2)
|
588 |
|
|
|
589 |
st.dataframe(
|
590 |
styled_df,
|
591 |
-
use_container_width=True
|
592 |
)
|
593 |
|
594 |
# Add visual separator
|
|
|
567 |
|
568 |
# Display the styled table
|
569 |
|
570 |
+
# ืคืื ืงืฆืื ืืฆืืืขืช ืืขืจืืื
|
571 |
+
def color_values(val):
|
572 |
+
try:
|
573 |
+
if pd.isna(val): # ืืืืงื ืื ืืขืจื ืืื NA
|
574 |
+
return ''
|
575 |
+
# ืืืจื ืืืกืคืจ ืื ืืคืฉืจ
|
576 |
+
num_val = pd.to_numeric(val, errors='coerce')
|
577 |
+
if pd.isna(num_val): # ืื ืื ื ืืชื ืืืืืจ ืืืกืคืจ
|
578 |
+
return ''
|
579 |
+
return 'color: green' if num_val > 0 else 'color: red' if num_val < 0 else 'color: black'
|
580 |
+
except:
|
581 |
return ''
|
|
|
|
|
582 |
|
583 |
+
# ืคืื ืงืฆืื ืืืืืฉืช ืืขืืืื ืืืืจืื ื
|
584 |
+
def highlight_last_column(df):
|
585 |
+
last_col = df.columns[-1]
|
586 |
+
return ['font-weight: bold' if col == last_col else '' for col in df.columns]
|
|
|
|
|
587 |
|
588 |
+
# ืขืืฆืื ืืืืื
|
589 |
styled_df = metric_df.style\
|
590 |
+
.apply(lambda s: highlight_last_column(metric_df), axis=0)\
|
591 |
+
.applymap(color_values)\
|
592 |
.set_properties(**{'text-align': 'center'})\
|
593 |
.format(precision=2)
|
594 |
|
595 |
+
# ืืฆืืช ืืืืื
|
596 |
st.dataframe(
|
597 |
styled_df,
|
598 |
+
use_container_width=True
|
599 |
)
|
600 |
|
601 |
# Add visual separator
|
app.py
CHANGED
@@ -567,28 +567,35 @@ with tab4:
|
|
567 |
|
568 |
# Display the styled table
|
569 |
|
570 |
-
|
571 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
return ''
|
573 |
-
color = 'green' if val > 0 else 'red' if val < 0 else 'black'
|
574 |
-
return f'color: {color}'
|
575 |
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
columns=data.columns
|
581 |
-
).iloc[0]
|
582 |
|
|
|
583 |
styled_df = metric_df.style\
|
584 |
-
.apply(highlight_last_column, axis=
|
585 |
-
.applymap(
|
586 |
.set_properties(**{'text-align': 'center'})\
|
587 |
.format(precision=2)
|
588 |
|
|
|
589 |
st.dataframe(
|
590 |
styled_df,
|
591 |
-
use_container_width=True
|
592 |
)
|
593 |
|
594 |
# Add visual separator
|
|
|
567 |
|
568 |
# Display the styled table
|
569 |
|
570 |
+
# ืคืื ืงืฆืื ืืฆืืืขืช ืืขืจืืื
|
571 |
+
def color_values(val):
|
572 |
+
try:
|
573 |
+
if pd.isna(val): # ืืืืงื ืื ืืขืจื ืืื NA
|
574 |
+
return ''
|
575 |
+
# ืืืจื ืืืกืคืจ ืื ืืคืฉืจ
|
576 |
+
num_val = pd.to_numeric(val, errors='coerce')
|
577 |
+
if pd.isna(num_val): # ืื ืื ื ืืชื ืืืืืจ ืืืกืคืจ
|
578 |
+
return ''
|
579 |
+
return 'color: green' if num_val > 0 else 'color: red' if num_val < 0 else 'color: black'
|
580 |
+
except:
|
581 |
return ''
|
|
|
|
|
582 |
|
583 |
+
# ืคืื ืงืฆืื ืืืืืฉืช ืืขืืืื ืืืืจืื ื
|
584 |
+
def highlight_last_column(df):
|
585 |
+
last_col = df.columns[-1]
|
586 |
+
return ['font-weight: bold' if col == last_col else '' for col in df.columns]
|
|
|
|
|
587 |
|
588 |
+
# ืขืืฆืื ืืืืื
|
589 |
styled_df = metric_df.style\
|
590 |
+
.apply(lambda s: highlight_last_column(metric_df), axis=0)\
|
591 |
+
.applymap(color_values)\
|
592 |
.set_properties(**{'text-align': 'center'})\
|
593 |
.format(precision=2)
|
594 |
|
595 |
+
# ืืฆืืช ืืืืื
|
596 |
st.dataframe(
|
597 |
styled_df,
|
598 |
+
use_container_width=True
|
599 |
)
|
600 |
|
601 |
# Add visual separator
|