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

Initial leaderboard setup

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +20 -13
  2. app.py +20 -13
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -567,28 +567,35 @@ with tab4:
567
 
568
  # Display the styled table
569
 
570
- def color_value(val):
571
- if not isinstance(val, (int, float)):
 
 
 
 
 
 
 
 
 
572
  return ''
573
- color = 'green' if val > 0 else 'red' if val < 0 else 'black'
574
- return f'color: {color}'
575
 
576
- def highlight_last_column(data):
577
- return pd.DataFrame(
578
- [[''] * (len(data.columns)-1) + ['font-weight: bold']],
579
- index=[0],
580
- columns=data.columns
581
- ).iloc[0]
582
 
 
583
  styled_df = metric_df.style\
584
- .apply(highlight_last_column, axis=1)\
585
- .applymap(color_value)\
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
- def color_value(val):
571
- if not isinstance(val, (int, float)):
 
 
 
 
 
 
 
 
 
572
  return ''
573
- color = 'green' if val > 0 else 'red' if val < 0 else 'black'
574
- return f'color: {color}'
575
 
576
- def highlight_last_column(data):
577
- return pd.DataFrame(
578
- [[''] * (len(data.columns)-1) + ['font-weight: bold']],
579
- index=[0],
580
- columns=data.columns
581
- ).iloc[0]
582
 
 
583
  styled_df = metric_df.style\
584
- .apply(highlight_last_column, axis=1)\
585
- .applymap(color_value)\
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