Custom_ROO_Tool / function_hold /NHL_functions.py
James McCool
Add NFL support to ROO build functions and Streamlit display
3c0866b
from numpy import nan as np_nan
from numpy import where as np_where
from numpy import random as np_random
from numpy import zeros as np_zeros
from numpy import array as np_array
from pandas import concat as pd_concat
from pandas import merge as pd_merge
from pandas import DataFrame
def DK_NHL_ROO_Build(projections_file, floor_var, ceiling_var, std_var, distribution_type):
total_sims = 1000
projects_raw = projections_file.copy()
projects_raw = projects_raw.replace("", np_nan)
dk_df = projects_raw.sort_values(by='Median', ascending=False)
basic_own_df = dk_df.copy()
basic_own_df['name_team'] = basic_own_df['Player'] + basic_own_df['Position']
def calculate_ownership(df, position):
# Filter the dataframe based on the position
frame = df[df['Position'].str.contains(position)]
# Calculate Small Field Own%
frame['Base Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (5 * (frame['Own'] - (frame['Own'].mean() / 1.5)) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Base Own%'] = np_where(
frame['Base Own%'] > 75,
75,
frame['Base Own%']
)
# Calculate Small Field Own%
frame['Small Field Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (6 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Small Field Own%'] = np_where(
frame['Small Field Own%'] > 75,
75,
frame['Small Field Own%']
)
# Calculate Large Field Own%
frame['Large Field Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (2.5 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Large Field Own%'] = np_where(
frame['Large Field Own%'] > 75,
75,
frame['Large Field Own%']
)
# Calculate Cash Own%
frame['Cash Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (8 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Cash Own%'] = np_where(
frame['Cash Own%'] > 75,
75,
frame['Cash Own%']
)
return frame
# Apply the function to each dataframe
w_frame = calculate_ownership(basic_own_df, 'W')
c_frame = calculate_ownership(basic_own_df, 'C')
d_frame = calculate_ownership(basic_own_df, 'D')
g_frame = calculate_ownership(basic_own_df, 'G')
w_reg_norm_var = 330 / w_frame['Base Own%'].sum()
w_small_norm_var = 330 / w_frame['Small Field Own%'].sum()
w_large_norm_var = 330 / w_frame['Large Field Own%'].sum()
w_cash_norm_var = 330 / w_frame['Cash Own%'].sum()
w_frame['Own'] = w_frame['Base Own%'] * w_reg_norm_var
w_frame['Small Field Own%'] = w_frame['Small Field Own%'] * w_small_norm_var
w_frame['Large Field Own%'] = w_frame['Large Field Own%'] * w_large_norm_var
w_frame['Cash Own%'] = w_frame['Cash Own%'] * w_cash_norm_var
c_reg_norm_var = 260 / c_frame['Base Own%'].sum()
c_small_norm_var = 260 / c_frame['Small Field Own%'].sum()
c_large_norm_var = 260 / c_frame['Large Field Own%'].sum()
c_cash_norm_var = 260 / c_frame['Cash Own%'].sum()
c_frame['Own'] = c_frame['Base Own%'] * c_reg_norm_var
c_frame['Small Field Own%'] = c_frame['Small Field Own%'] * c_small_norm_var
c_frame['Large Field Own%'] = c_frame['Large Field Own%'] * c_large_norm_var
c_frame['Cash Own%'] = c_frame['Cash Own%'] * c_cash_norm_var
d_reg_norm_var = 210 / d_frame['Base Own%'].sum()
d_small_norm_var = 210 / d_frame['Small Field Own%'].sum()
d_large_norm_var = 210 / d_frame['Large Field Own%'].sum()
d_cash_norm_var = 210 / d_frame['Cash Own%'].sum()
d_frame['Own'] = d_frame['Base Own%'] * d_reg_norm_var
d_frame['Small Field Own%'] = d_frame['Small Field Own%'] * d_small_norm_var
d_frame['Large Field Own%'] = d_frame['Large Field Own%'] * d_large_norm_var
d_frame['Cash Own%'] = d_frame['Cash Own%'] * d_cash_norm_var
g_reg_norm_var = 100 / g_frame['Base Own%'].sum()
g_small_norm_var = 100 / g_frame['Small Field Own%'].sum()
g_large_norm_var = 100 / g_frame['Large Field Own%'].sum()
g_cash_norm_var = 100 / g_frame['Cash Own%'].sum()
g_frame['Own'] = g_frame['Base Own%'] * g_reg_norm_var
g_frame['Small Field Own%'] = g_frame['Small Field Own%'] * g_small_norm_var
g_frame['Large Field Own%'] = g_frame['Large Field Own%'] * g_large_norm_var
g_frame['Cash Own%'] = g_frame['Cash Own%'] * g_cash_norm_var
basic_own_df = pd_concat([w_frame, c_frame, d_frame, g_frame])
basic_own_dict = dict(zip(basic_own_df.Player, basic_own_df.Own))
small_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Small Field Own%']))
large_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Large Field Own%']))
cash_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Cash Own%']))
basic_team_dict = dict(zip(basic_own_df.name_team, basic_own_df.Team))
basic_opp_dict = dict(zip(basic_own_df.Player, basic_own_df.Opp))
flex_file = basic_own_df.copy()
flex_file['Floor_raw'] = flex_file['Median'] * .25
flex_file['Ceiling_raw'] = flex_file['Median'] * 2
flex_file['Floor'] = np_where(flex_file['Position'] == 'G', flex_file['Median'] * .5, flex_file['Floor_raw'])
flex_file['Floor'] = np_where(flex_file['Position'] == 'D', flex_file['Median'] * .1, flex_file['Floor_raw'])
flex_file['Ceiling'] = np_where(flex_file['Position'] == 'G', flex_file['Median'] * 1.75, flex_file['Ceiling_raw'])
flex_file['Ceiling'] = np_where(flex_file['Position'] == 'D', flex_file['Median'] * 1.75, flex_file['Ceiling_raw'])
flex_file['STD'] = flex_file['Median'] / 3
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
flex_file = flex_file.reset_index(drop=True)
hold_file = flex_file.copy()
overall_file = flex_file.copy()
salary_file = flex_file.copy()
try:
overall_floor_gpu = np_array(overall_file['Floor'])
overall_ceiling_gpu = np_array(overall_file['Ceiling'])
overall_median_gpu = np_array(overall_file['Median'])
overall_std_gpu = np_array(overall_file['STD'])
overall_salary_gpu = np_array(overall_file['Salary'])
data_shape = (len(overall_file['Player']), total_sims) # Example: 1000 rows
salary_array = np_zeros(data_shape)
sim_array = np_zeros(data_shape)
for x in range(0, total_sims):
result_gpu = overall_salary_gpu
salary_array[:, x] = result_gpu
cupy_array = salary_array
salary_file = salary_file.reset_index(drop=True)
salary_cupy = DataFrame(cupy_array, columns=list(range(0, total_sims)))
salary_check_file = pd_concat([salary_file, salary_cupy], axis=1)
except:
for x in range(0,total_sims):
salary_file[x] = salary_file['Salary']
salary_check_file = salary_file.copy()
salary_file=salary_check_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
salary_file = salary_file.div(1000)
try:
for x in range(0, total_sims):
if distribution_type == 'normal':
# Normal distribution (existing logic)
result_gpu = np_random.normal(overall_median_gpu, overall_std_gpu)
elif distribution_type == 'poisson':
# Poisson distribution - using median as lambda
result_gpu = np_random.poisson(overall_median_gpu)
elif distribution_type == 'bimodal':
# Bimodal distribution - mixture of two normal distributions
# First peak centered at 80% of median, second at 120% of median
if np_random.random() < 0.5:
result_gpu = np_random.normal(overall_floor_gpu, overall_std_gpu)
else:
result_gpu = np_random.normal(overall_ceiling_gpu, overall_std_gpu)
else:
raise ValueError("Invalid distribution type. Must be 'normal', 'poisson', or 'bimodal'")
sim_array[:, x] = result_gpu
add_array = sim_array
overall_file = overall_file.reset_index(drop=True)
df2 = DataFrame(add_array, columns=list(range(0, total_sims)))
check_file = pd_concat([overall_file, df2], axis=1)
except:
for x in range(0,total_sims):
if distribution_type == 'normal':
overall_file[x] = np_random.normal(overall_file['Median'], overall_file['STD'])
elif distribution_type == 'poisson':
overall_file[x] = np_random.poisson(overall_file['Median'])
elif distribution_type == 'bimodal':
# Bimodal distribution fallback
if np_random.random() < 0.5:
overall_file[x] = np_random.normal(overall_file['Median'] * 0.8, overall_file['STD'])
else:
overall_file[x] = np_random.normal(overall_file['Median'] * 1.2, overall_file['STD'])
check_file = overall_file.copy()
overall_file=check_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
players_only = hold_file[['Player']]
raw_lineups_file = players_only
for x in range(0,total_sims):
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
players_only[x] = raw_lineups_file[x].rank(ascending=False)
players_only=players_only.drop(['Player'], axis=1)
salary_2x_check = (overall_file - (salary_file*2))
salary_3x_check = (overall_file - (salary_file*3))
salary_4x_check = (overall_file - (salary_file*4))
players_only['Average_Rank'] = players_only.mean(axis=1)
players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
players_only['2x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
players_only['3x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
players_only['4x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
players_only['Player'] = hold_file[['Player']]
final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
final_Proj = pd_merge(hold_file, final_outcomes, on="Player")
final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
final_Proj['Own'] = final_Proj['Player'].map(basic_own_dict).astype(float)
final_Proj['Small Field Own%'] = final_Proj['Player'].map(small_own_dict).astype(float)
final_Proj['Large Field Own%'] = final_Proj['Player'].map(large_own_dict).astype(float)
final_Proj['Cash Own%'] = final_Proj['Player'].map(cash_own_dict).astype(float)
final_Proj['name_team'] = final_Proj['Player'] + final_Proj['Position']
final_Proj['Team'] = final_Proj['name_team'].map(basic_team_dict)
final_Proj['Opp'] = final_Proj['Player'].map(basic_opp_dict)
final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own',
'Small Field Own%', 'Large Field Own%', 'Cash Own%']]
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
return final_Proj.copy()
def FD_NHL_ROO_Build(projections_file, floor_var, ceiling_var, std_var, distribution_type):
total_sims = 1000
projects_raw = projections_file.copy()
fd_df = projects_raw.sort_values(by='Median', ascending=False)
basic_own_df = fd_df.copy()
basic_own_df['name_team'] = basic_own_df['Player'] + basic_own_df['Position']
def calculate_ownership(df, position):
# Filter the dataframe based on the position
frame = df[df['Position'].str.contains(position)]
frame['Base Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (5 * (frame['Own'] - (frame['Own'].mean() / 1.5)) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Base Own%'] = np_where(
frame['Base Own%'] > 75,
75,
frame['Base Own%']
)
# Calculate Small Field Own%
frame['Small Field Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (6 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Small Field Own%'] = np_where(
frame['Small Field Own%'] > 75,
75,
frame['Small Field Own%']
)
# Calculate Large Field Own%
frame['Large Field Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (2.5 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Large Field Own%'] = np_where(
frame['Large Field Own%'] > 75,
75,
frame['Large Field Own%']
)
# Calculate Cash Own%
frame['Cash Own%'] = np_where(
(frame['Own'] - frame['Own'].mean() >= 0),
frame['Own'] * (8 * (frame['Own'] - frame['Own'].mean()) / 100) + frame['Own'].mean(),
frame['Own']
)
frame['Cash Own%'] = np_where(
frame['Cash Own%'] > 75,
75,
frame['Cash Own%']
)
return frame
# Apply the function to each dataframe
w_frame = calculate_ownership(basic_own_df, 'W')
c_frame = calculate_ownership(basic_own_df, 'C')
d_frame = calculate_ownership(basic_own_df, 'D')
g_frame = calculate_ownership(basic_own_df, 'G')
w_reg_norm_var = 295 / w_frame['Base Own%'].sum()
w_small_norm_var = 295 / w_frame['Small Field Own%'].sum()
w_large_norm_var = 295 / w_frame['Large Field Own%'].sum()
w_cash_norm_var = 295 / w_frame['Cash Own%'].sum()
w_frame['Own'] = w_frame['Base Own%'] * w_reg_norm_var
w_frame['Small Field Own%'] = w_frame['Small Field Own%'] * w_small_norm_var
w_frame['Large Field Own%'] = w_frame['Large Field Own%'] * w_large_norm_var
w_frame['Cash Own%'] = w_frame['Cash Own%'] * w_cash_norm_var
c_reg_norm_var = 295 / c_frame['Base Own%'].sum()
c_small_norm_var = 295 / c_frame['Small Field Own%'].sum()
c_large_norm_var = 295 / c_frame['Large Field Own%'].sum()
c_cash_norm_var = 295 / c_frame['Cash Own%'].sum()
c_frame['Own'] = c_frame['Base Own%'] * c_reg_norm_var
c_frame['Small Field Own%'] = c_frame['Small Field Own%'] * c_small_norm_var
c_frame['Large Field Own%'] = c_frame['Large Field Own%'] * c_large_norm_var
c_frame['Cash Own%'] = c_frame['Cash Own%'] * c_cash_norm_var
d_reg_norm_var = 210 / d_frame['Base Own%'].sum()
d_small_norm_var = 210 / d_frame['Small Field Own%'].sum()
d_large_norm_var = 210 / d_frame['Large Field Own%'].sum()
d_cash_norm_var = 210 / d_frame['Cash Own%'].sum()
d_frame['Own'] = d_frame['Base Own%'] * d_reg_norm_var
d_frame['Small Field Own%'] = d_frame['Small Field Own%'] * d_small_norm_var
d_frame['Large Field Own%'] = d_frame['Large Field Own%'] * d_large_norm_var
d_frame['Cash Own%'] = d_frame['Cash Own%'] * d_cash_norm_var
g_reg_norm_var = 100 / g_frame['Base Own%'].sum()
g_small_norm_var = 100 / g_frame['Small Field Own%'].sum()
g_large_norm_var = 100 / g_frame['Large Field Own%'].sum()
g_cash_norm_var = 100 / g_frame['Cash Own%'].sum()
g_frame['Own'] = g_frame['Base Own%'] * g_reg_norm_var
g_frame['Small Field Own%'] = g_frame['Small Field Own%'] * g_small_norm_var
g_frame['Large Field Own%'] = g_frame['Large Field Own%'] * g_large_norm_var
g_frame['Cash Own%'] = g_frame['Cash Own%'] * g_cash_norm_var
basic_own_df = pd_concat([w_frame, c_frame, d_frame, g_frame])
basic_own_dict = dict(zip(basic_own_df.Player, basic_own_df.Own))
small_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Small Field Own%']))
large_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Large Field Own%']))
cash_own_dict = dict(zip(basic_own_df.Player, basic_own_df['Cash Own%']))
basic_team_dict = dict(zip(basic_own_df.name_team, basic_own_df.Team))
basic_opp_dict = dict(zip(basic_own_df.Player, basic_own_df.Opp))
flex_file = basic_own_df.copy()
flex_file['Floor_raw'] = flex_file['Median'] * .25
flex_file['Ceiling_raw'] = flex_file['Median'] * 2
flex_file['Floor'] = np_where(flex_file['Position'] == 'G', flex_file['Median'] * .5, flex_file['Floor_raw'])
flex_file['Floor'] = np_where(flex_file['Position'] == 'D', flex_file['Median'] * .1, flex_file['Floor_raw'])
flex_file['Ceiling'] = np_where(flex_file['Position'] == 'G', flex_file['Median'] * 1.75, flex_file['Ceiling_raw'])
flex_file['Ceiling'] = np_where(flex_file['Position'] == 'D', flex_file['Median'] * 1.75, flex_file['Ceiling_raw'])
flex_file['STD'] = flex_file['Median'] / 3
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
flex_file = flex_file.reset_index(drop=True)
hold_file = flex_file.copy()
overall_file = flex_file.copy()
salary_file = flex_file.copy()
try:
overall_floor_gpu = np_array(overall_file['Floor'])
overall_ceiling_gpu = np_array(overall_file['Ceiling'])
overall_median_gpu = np_array(overall_file['Median'])
overall_std_gpu = np_array(overall_file['STD'])
overall_salary_gpu = np_array(overall_file['Salary'])
data_shape = (len(overall_file['Player']), total_sims) # Example: 1000 rows
salary_array = np_zeros(data_shape)
sim_array = np_zeros(data_shape)
for x in range(0, total_sims):
result_gpu = overall_salary_gpu
salary_array[:, x] = result_gpu
cupy_array = salary_array
salary_file = salary_file.reset_index(drop=True)
salary_cupy = DataFrame(cupy_array, columns=list(range(0, total_sims)))
salary_check_file = pd_concat([salary_file, salary_cupy], axis=1)
except:
for x in range(0,total_sims):
salary_file[x] = salary_file['Salary']
salary_check_file = salary_file.copy()
salary_file=salary_check_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
salary_file = salary_file.div(1000)
try:
for x in range(0, total_sims):
if distribution_type == 'normal':
# Normal distribution (existing logic)
result_gpu = np_random.normal(overall_median_gpu, overall_std_gpu)
elif distribution_type == 'poisson':
# Poisson distribution - using median as lambda
result_gpu = np_random.poisson(overall_median_gpu)
elif distribution_type == 'bimodal':
# Bimodal distribution - mixture of two normal distributions
# First peak centered at 80% of median, second at 120% of median
if np_random.random() < 0.5:
result_gpu = np_random.normal(overall_floor_gpu, overall_std_gpu)
else:
result_gpu = np_random.normal(overall_ceiling_gpu, overall_std_gpu)
else:
raise ValueError("Invalid distribution type. Must be 'normal', 'poisson', or 'bimodal'")
sim_array[:, x] = result_gpu
add_array = sim_array
overall_file = overall_file.reset_index(drop=True)
df2 = DataFrame(add_array, columns=list(range(0, total_sims)))
check_file = pd_concat([overall_file, df2], axis=1)
except:
for x in range(0,total_sims):
if distribution_type == 'normal':
overall_file[x] = np_random.normal(overall_file['Median'], overall_file['STD'])
elif distribution_type == 'poisson':
overall_file[x] = np_random.poisson(overall_file['Median'])
elif distribution_type == 'bimodal':
# Bimodal distribution fallback
if np_random.random() < 0.5:
overall_file[x] = np_random.normal(overall_file['Median'] * 0.8, overall_file['STD'])
else:
overall_file[x] = np_random.normal(overall_file['Median'] * 1.2, overall_file['STD'])
check_file = overall_file.copy()
overall_file=check_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
players_only = hold_file[['Player']]
raw_lineups_file = players_only
for x in range(0,total_sims):
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
players_only[x] = raw_lineups_file[x].rank(ascending=False)
players_only=players_only.drop(['Player'], axis=1)
salary_2x_check = (overall_file - (salary_file*2))
salary_3x_check = (overall_file - (salary_file*3))
salary_4x_check = (overall_file - (salary_file*4))
players_only['Average_Rank'] = players_only.mean(axis=1)
players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
players_only['2x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
players_only['3x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
players_only['4x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
players_only['Player'] = hold_file[['Player']]
final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
final_Proj = pd_merge(hold_file, final_outcomes, on="Player")
final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
final_Proj['Own'] = final_Proj['Player'].map(basic_own_dict).astype(float)
final_Proj['Small Field Own%'] = final_Proj['Player'].map(small_own_dict).astype(float)
final_Proj['Large Field Own%'] = final_Proj['Player'].map(large_own_dict).astype(float)
final_Proj['Cash Own%'] = final_Proj['Player'].map(cash_own_dict).astype(float)
final_Proj['name_team'] = final_Proj['Player'] + final_Proj['Position']
final_Proj['Team'] = final_Proj['name_team'].map(basic_team_dict)
final_Proj['Opp'] = final_Proj['Player'].map(basic_opp_dict)
final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own',
'Small Field Own%', 'Large Field Own%', 'Cash Own%']]
final_Proj['Salary'] = final_Proj['Salary'].astype(int)
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
return final_Proj.copy()