Spaces:
Running
Running
James McCool
commited on
Commit
·
292c61c
1
Parent(s):
d1f63f3
Refactor Cpt_Own calculation in app.py to improve accuracy and add clipping for TEAM position
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
import gspread
|
|
|
4 |
|
5 |
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
6 |
"https://www.googleapis.com/auth/drive"]
|
@@ -246,7 +247,8 @@ with tab2:
|
|
246 |
elif pos_var1 != 'All':
|
247 |
display = display[display['Position'].str.contains(pos_var1)]
|
248 |
display = display.drop(columns=['type', 'league', 'Timestamp'])
|
249 |
-
display['Cpt_Own'] = (
|
|
|
250 |
scale_var = display['Cpt_Own'].sum()
|
251 |
display['Cpt_Own'] = display['Cpt_Own'] * (100 / scale_var)
|
252 |
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=750, use_container_width = True)
|
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
import gspread
|
4 |
+
import numpy as np
|
5 |
|
6 |
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
7 |
"https://www.googleapis.com/auth/drive"]
|
|
|
247 |
elif pos_var1 != 'All':
|
248 |
display = display[display['Position'].str.contains(pos_var1)]
|
249 |
display = display.drop(columns=['type', 'league', 'Timestamp'])
|
250 |
+
display['Cpt_Own'] = (display['Own'] / 2) * ((100 - (100-display['Own']))/100)
|
251 |
+
display['Cpt_Own'] = np.where(display['Position'] == 'TEAM', display['Cpt_Own'].clip(upper=.25), display['Cpt_Own'])
|
252 |
scale_var = display['Cpt_Own'].sum()
|
253 |
display['Cpt_Own'] = display['Cpt_Own'] * (100 / scale_var)
|
254 |
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=750, use_container_width = True)
|