Spaces:
Running
Running
Jon Solow
commited on
Commit
Β·
8bbcbe6
1
Parent(s):
286c902
Add approximate value calculation
Browse files- src/config.py +1 -0
- src/pages/1_Keepers.py +9 -2
src/config.py
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
LEAGUE_NAME = "LOFG"
|
2 |
DEFAULT_ICON = "π"
|
|
|
|
1 |
LEAGUE_NAME = "LOFG"
|
2 |
DEFAULT_ICON = "π"
|
3 |
+
LEAGUE_NUMBER_TEAMS = 12
|
src/pages/1_Keepers.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
-
from config import DEFAULT_ICON, LEAGUE_NAME
|
6 |
from streamlit_filter import filter_dataframe
|
7 |
|
8 |
|
@@ -21,6 +21,11 @@ def load_adp() -> pd.DataFrame:
|
|
21 |
return df
|
22 |
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
@st.cache_data
|
25 |
def load_data():
|
26 |
data = pd.read_csv(os.path.join(os.path.dirname(__file__), KEEPER_DATA_URL), index_col=0)
|
@@ -36,7 +41,7 @@ def load_data():
|
|
36 |
# Merge ADP
|
37 |
df_adp = load_adp()
|
38 |
data = data.merge(df_adp, how="left", left_on="fantasypros_id", right_on="fp_id", suffixes=("", "_adp"))
|
39 |
-
|
40 |
return data, teams_list
|
41 |
|
42 |
|
@@ -54,7 +59,9 @@ def filtered_keeper_dataframe(data: pd.DataFrame, teams_list: list[str]):
|
|
54 |
"years_eligible",
|
55 |
"eligible",
|
56 |
"ecr_1qb",
|
|
|
57 |
"ecr_2qb",
|
|
|
58 |
"ecr_pos",
|
59 |
]
|
60 |
|
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
+
from config import DEFAULT_ICON, LEAGUE_NAME, LEAGUE_NUMBER_TEAMS
|
6 |
from streamlit_filter import filter_dataframe
|
7 |
|
8 |
|
|
|
21 |
return df
|
22 |
|
23 |
|
24 |
+
def add_opinionated_keeper_value(df: pd.DataFrame):
|
25 |
+
for score_fmt in ["1qb", "2qb"]:
|
26 |
+
df[f"value_{score_fmt}"] = (df["keeper_cost"] - 0.5) * LEAGUE_NUMBER_TEAMS - df[f"ecr_{score_fmt}"]
|
27 |
+
|
28 |
+
|
29 |
@st.cache_data
|
30 |
def load_data():
|
31 |
data = pd.read_csv(os.path.join(os.path.dirname(__file__), KEEPER_DATA_URL), index_col=0)
|
|
|
41 |
# Merge ADP
|
42 |
df_adp = load_adp()
|
43 |
data = data.merge(df_adp, how="left", left_on="fantasypros_id", right_on="fp_id", suffixes=("", "_adp"))
|
44 |
+
add_opinionated_keeper_value(data)
|
45 |
return data, teams_list
|
46 |
|
47 |
|
|
|
59 |
"years_eligible",
|
60 |
"eligible",
|
61 |
"ecr_1qb",
|
62 |
+
"value_1qb",
|
63 |
"ecr_2qb",
|
64 |
+
"value_2qb",
|
65 |
"ecr_pos",
|
66 |
]
|
67 |
|