Roni Goldshmidt commited on
Commit
a7bc2a5
ยท
1 Parent(s): e55ea34

Initial leaderboard setup

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +5 -24
  2. 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 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
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 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
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("---")