Roni Goldshmidt
commited on
Commit
ยท
a7bc2a5
1
Parent(s):
e55ea34
Initial leaderboard setup
Browse files- .ipynb_checkpoints/app-checkpoint.py +5 -24
- app.py +5 -24
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -566,37 +566,18 @@ with tab4:
|
|
566 |
])
|
567 |
|
568 |
# Display the styled table
|
569 |
-
|
570 |
-
# ืคืื ืงืฆืื ืืฆืืืขืช ืืขืจืืื
|
571 |
-
def color_values(val):
|
572 |
try:
|
573 |
-
if
|
574 |
-
|
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 |
-
.
|
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
|
602 |
st.markdown("---")
|
|
|
566 |
])
|
567 |
|
568 |
# Display the styled table
|
569 |
+
def color_negative_positive(val):
|
|
|
|
|
570 |
try:
|
571 |
+
color = 'green' if float(val) > 0 else 'red' if float(val) < 0 else 'black'
|
572 |
+
return f'color: {color}'
|
|
|
|
|
|
|
|
|
|
|
573 |
except:
|
574 |
return ''
|
575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
styled_df = metric_df.style\
|
577 |
+
.applymap(color_negative_positive)\
|
|
|
|
|
578 |
.format(precision=2)
|
579 |
|
580 |
+
st.dataframe(styled_df, use_container_width=True)
|
|
|
|
|
|
|
|
|
581 |
|
582 |
# Add visual separator
|
583 |
st.markdown("---")
|
app.py
CHANGED
@@ -566,37 +566,18 @@ with tab4:
|
|
566 |
])
|
567 |
|
568 |
# Display the styled table
|
569 |
-
|
570 |
-
# ืคืื ืงืฆืื ืืฆืืืขืช ืืขืจืืื
|
571 |
-
def color_values(val):
|
572 |
try:
|
573 |
-
if
|
574 |
-
|
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 |
-
.
|
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
|
602 |
st.markdown("---")
|
|
|
566 |
])
|
567 |
|
568 |
# Display the styled table
|
569 |
+
def color_negative_positive(val):
|
|
|
|
|
570 |
try:
|
571 |
+
color = 'green' if float(val) > 0 else 'red' if float(val) < 0 else 'black'
|
572 |
+
return f'color: {color}'
|
|
|
|
|
|
|
|
|
|
|
573 |
except:
|
574 |
return ''
|
575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
styled_df = metric_df.style\
|
577 |
+
.applymap(color_negative_positive)\
|
|
|
|
|
578 |
.format(precision=2)
|
579 |
|
580 |
+
st.dataframe(styled_df, use_container_width=True)
|
|
|
|
|
|
|
|
|
581 |
|
582 |
# Add visual separator
|
583 |
st.markdown("---")
|