James McCool
commited on
Commit
Β·
8587197
1
Parent(s):
b2e149b
Updated projections management to include default values of 0 for missing players and adjusted change detection to include team information.
Browse files
app.py
CHANGED
|
@@ -1775,7 +1775,7 @@ if selected_tab == 'Projections Management':
|
|
| 1775 |
missing_df = pd.DataFrame(missing_rows)
|
| 1776 |
projections_editor_df = pd.concat([projections_editor_df, missing_df], ignore_index=True)
|
| 1777 |
|
| 1778 |
-
st.info(f"π Found {len(missing_players)} player(s) in portfolio not in projections. They have been added below with
|
| 1779 |
|
| 1780 |
# Define column configuration for the data editor
|
| 1781 |
column_config = {
|
|
@@ -1791,7 +1791,6 @@ if selected_tab == 'Projections Management':
|
|
| 1791 |
),
|
| 1792 |
'team': st.column_config.TextColumn(
|
| 1793 |
'Team',
|
| 1794 |
-
disabled=True,
|
| 1795 |
width='small'
|
| 1796 |
),
|
| 1797 |
'salary': st.column_config.NumberColumn(
|
|
@@ -1859,7 +1858,7 @@ if selected_tab == 'Projections Management':
|
|
| 1859 |
# Check for changes and update
|
| 1860 |
if not edited_df.equals(filtered_df):
|
| 1861 |
# Find which rows changed
|
| 1862 |
-
changed_mask = ~(edited_df[['median', 'ownership', 'captain ownership']] == filtered_df[['median', 'ownership', 'captain ownership']]).all(axis=1)
|
| 1863 |
changed_rows = edited_df[changed_mask]
|
| 1864 |
|
| 1865 |
if len(changed_rows) > 0:
|
|
@@ -1871,6 +1870,7 @@ if selected_tab == 'Projections Management':
|
|
| 1871 |
orig_idx = st.session_state['projections_df'][st.session_state['projections_df']['player_names'] == player_name].index
|
| 1872 |
if len(orig_idx) > 0:
|
| 1873 |
# Player exists in projections_df - update existing row
|
|
|
|
| 1874 |
st.session_state['projections_df'].loc[orig_idx[0], 'median'] = row['median']
|
| 1875 |
st.session_state['projections_df'].loc[orig_idx[0], 'ownership'] = row['ownership']
|
| 1876 |
st.session_state['projections_df'].loc[orig_idx[0], 'captain ownership'] = row['captain ownership']
|
|
@@ -1889,6 +1889,7 @@ if selected_tab == 'Projections Management':
|
|
| 1889 |
|
| 1890 |
# Update map_dict entries
|
| 1891 |
if 'map_dict' in st.session_state:
|
|
|
|
| 1892 |
st.session_state['map_dict']['proj_map'][player_name] = float(row['median'])
|
| 1893 |
st.session_state['map_dict']['own_map'][player_name] = float(row['ownership'])
|
| 1894 |
|
|
|
|
| 1775 |
missing_df = pd.DataFrame(missing_rows)
|
| 1776 |
projections_editor_df = pd.concat([projections_editor_df, missing_df], ignore_index=True)
|
| 1777 |
|
| 1778 |
+
st.info(f"π Found {len(missing_players)} player(s) in portfolio not in projections. They have been added below with values of 0 for median, ownership, and captain ownership.")
|
| 1779 |
|
| 1780 |
# Define column configuration for the data editor
|
| 1781 |
column_config = {
|
|
|
|
| 1791 |
),
|
| 1792 |
'team': st.column_config.TextColumn(
|
| 1793 |
'Team',
|
|
|
|
| 1794 |
width='small'
|
| 1795 |
),
|
| 1796 |
'salary': st.column_config.NumberColumn(
|
|
|
|
| 1858 |
# Check for changes and update
|
| 1859 |
if not edited_df.equals(filtered_df):
|
| 1860 |
# Find which rows changed
|
| 1861 |
+
changed_mask = ~(edited_df[['team', 'median', 'ownership', 'captain ownership']] == filtered_df[['team', 'median', 'ownership', 'captain ownership']]).all(axis=1)
|
| 1862 |
changed_rows = edited_df[changed_mask]
|
| 1863 |
|
| 1864 |
if len(changed_rows) > 0:
|
|
|
|
| 1870 |
orig_idx = st.session_state['projections_df'][st.session_state['projections_df']['player_names'] == player_name].index
|
| 1871 |
if len(orig_idx) > 0:
|
| 1872 |
# Player exists in projections_df - update existing row
|
| 1873 |
+
st.session_state['projections_df'].loc[orig_idx[0], 'team'] = row['team']
|
| 1874 |
st.session_state['projections_df'].loc[orig_idx[0], 'median'] = row['median']
|
| 1875 |
st.session_state['projections_df'].loc[orig_idx[0], 'ownership'] = row['ownership']
|
| 1876 |
st.session_state['projections_df'].loc[orig_idx[0], 'captain ownership'] = row['captain ownership']
|
|
|
|
| 1889 |
|
| 1890 |
# Update map_dict entries
|
| 1891 |
if 'map_dict' in st.session_state:
|
| 1892 |
+
st.session_state['map_dict']['team_map'][player_name] = str(row['team'])
|
| 1893 |
st.session_state['map_dict']['proj_map'][player_name] = float(row['median'])
|
| 1894 |
st.session_state['map_dict']['own_map'][player_name] = float(row['ownership'])
|
| 1895 |
|