Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -407,61 +407,56 @@ with tab2:
|
|
407 |
lineup_final = lineup_final.drop(columns=['Names'])
|
408 |
lineup_final.rename(columns={"sorted": "Names"}, inplace = True)
|
409 |
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
# if line_hold.iat[pname,1] == 'TE':
|
445 |
-
# if line_hold.iat[pname,0] not in p_used:
|
446 |
-
# sorted_lineup.append(line_hold.iat[pname,0])
|
447 |
-
# tevar = tevar + 1
|
448 |
-
# p_used.extend(sorted_lineup)
|
449 |
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
|
466 |
lineup_test = lineup_final
|
467 |
lineup_final = lineup_final.T
|
@@ -493,32 +488,33 @@ with tab2:
|
|
493 |
x += 1
|
494 |
|
495 |
if site_var1 == 'Draftkings':
|
496 |
-
portfolio.rename(columns={0: "C1", 1: "C2", 2: "W1", 3: "W2", 4: "
|
497 |
elif site_var1 == 'Fanduel':
|
498 |
-
portfolio.rename(columns={0: "
|
499 |
portfolio = portfolio.dropna()
|
500 |
portfolio = portfolio.reset_index()
|
501 |
portfolio['Lineup_num'] = portfolio['index'] + 1
|
502 |
portfolio.rename(columns={'Lineup_num': "Lineup"}, inplace = True)
|
503 |
portfolio = portfolio.set_index('Lineup')
|
504 |
portfolio = portfolio.drop(columns=['index'])
|
505 |
-
|
506 |
-
final_outcomes = portfolio[['C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'UTIL', 'G', 'Cost', 'Proj', 'Own']]
|
507 |
-
final_outcomes = final_outcomes.set_axis(['C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'UTIL', 'G', 'Cost', 'Proj', 'Own'], axis=1)
|
508 |
-
final_outcomes_export = pd.DataFrame()
|
509 |
-
final_outcomes_export['C1'] = final_outcomes['C1']
|
510 |
-
final_outcomes_export['C2'] = final_outcomes['C2']
|
511 |
-
final_outcomes_export['W1'] = final_outcomes['W1']
|
512 |
-
final_outcomes_export['W2'] = final_outcomes['W2']
|
513 |
-
final_outcomes_export['W3'] = final_outcomes['W3']
|
514 |
-
final_outcomes_export['D1'] = final_outcomes['D1']
|
515 |
-
final_outcomes_export['D2'] = final_outcomes['D2']
|
516 |
-
final_outcomes_export['UTIL'] = final_outcomes['UTIL']
|
517 |
-
final_outcomes_export['G'] = final_outcomes['G']
|
518 |
-
final_outcomes_export['Salary'] = final_outcomes['Cost']
|
519 |
-
final_outcomes_export['Own'] = final_outcomes['Own']
|
520 |
-
final_outcomes_export['Proj'] = final_outcomes['Proj']
|
521 |
if site_var1 == 'Draftkings':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
final_outcomes_export['C1'].replace(dkid_dict, inplace=True)
|
523 |
final_outcomes_export['C2'].replace(dkid_dict, inplace=True)
|
524 |
final_outcomes_export['W1'].replace(dkid_dict, inplace=True)
|
@@ -529,16 +525,32 @@ with tab2:
|
|
529 |
final_outcomes_export['UTIL'].replace(dkid_dict, inplace=True)
|
530 |
final_outcomes_export['G'].replace(dkid_dict, inplace=True)
|
531 |
elif site_var1 == 'Fanduel':
|
532 |
-
|
533 |
-
|
534 |
-
final_outcomes_export
|
535 |
-
final_outcomes_export['
|
536 |
-
final_outcomes_export['
|
537 |
-
final_outcomes_export['
|
538 |
-
final_outcomes_export['
|
539 |
-
final_outcomes_export['
|
540 |
-
final_outcomes_export['
|
541 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
player_freq = pd.DataFrame(np.column_stack(np.unique(portfolio.iloc[:,0:8].values, return_counts=True)),
|
543 |
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
544 |
player_freq['Freq'] = player_freq['Freq'].astype(int)
|
@@ -559,7 +571,7 @@ with tab2:
|
|
559 |
st.download_button(
|
560 |
label="Export Optimals",
|
561 |
data=convert_df_to_csv(final_outcomes_export),
|
562 |
-
file_name='
|
563 |
mime='text/csv',
|
564 |
)
|
565 |
with freq_container:
|
|
|
407 |
lineup_final = lineup_final.drop(columns=['Names'])
|
408 |
lineup_final.rename(columns={"sorted": "Names"}, inplace = True)
|
409 |
|
410 |
+
elif site_var1 == 'Fanduel':
|
411 |
+
line_hold = lineup_final[['Names']]
|
412 |
+
line_hold['pos'] = line_hold['Names'].map(player_pos)
|
413 |
+
|
414 |
+
cvar = 0
|
415 |
+
for pname in range(0,len(line_hold)):
|
416 |
+
if cvar == 2:
|
417 |
+
pname = len(line_hold)
|
418 |
+
elif cvar < 2:
|
419 |
+
if line_hold.iat[pname,1] == 'C':
|
420 |
+
if line_hold.iat[pname,0] not in p_used:
|
421 |
+
sorted_lineup.append(line_hold.iat[pname,0])
|
422 |
+
cvar = cvar + 1
|
423 |
+
p_used.extend(sorted_lineup)
|
424 |
+
wvar = 0
|
425 |
+
for pname in range(0,len(line_hold)):
|
426 |
+
if wvar == 2:
|
427 |
+
pname = len(line_hold)
|
428 |
+
elif wvar < 2:
|
429 |
+
if line_hold.iat[pname,1] == 'C':
|
430 |
+
if line_hold.iat[pname,0] not in p_used:
|
431 |
+
sorted_lineup.append(line_hold.iat[pname,0])
|
432 |
+
wvar = wvar + 1
|
433 |
+
p_used.extend(sorted_lineup)
|
434 |
+
dvar = 0
|
435 |
+
for pname in range(0,len(line_hold)):
|
436 |
+
if dvar == 2:
|
437 |
+
pname = len(line_hold)
|
438 |
+
elif dvar < 2:
|
439 |
+
if line_hold.iat[pname,1] == "D":
|
440 |
+
if line_hold.iat[pname,0] not in p_used:
|
441 |
+
sorted_lineup.append(line_hold.iat[pname,0])
|
442 |
+
dvar = dvar + 1
|
443 |
+
p_used.extend(sorted_lineup)
|
|
|
|
|
|
|
|
|
|
|
444 |
|
445 |
+
for pname in range(0,len(line_hold)):
|
446 |
+
if line_hold.iat[pname,1] != 'G':
|
447 |
+
if line_hold.iat[pname,0] not in p_used:
|
448 |
+
sorted_lineup.append(line_hold.iat[pname,0])
|
449 |
+
p_used.extend(sorted_lineup)
|
450 |
|
451 |
+
for pname in range(0,len(line_hold)):
|
452 |
+
if line_hold.iat[pname,1] == 'G':
|
453 |
+
if line_hold.iat[pname,0] not in p_used:
|
454 |
+
sorted_lineup.append(line_hold.iat[pname,0])
|
455 |
+
p_used.extend(sorted_lineup)
|
456 |
|
457 |
+
lineup_final['sorted'] = sorted_lineup
|
458 |
+
lineup_final = lineup_final.drop(columns=['Names'])
|
459 |
+
lineup_final.rename(columns={"sorted": "Names"}, inplace = True)
|
460 |
|
461 |
lineup_test = lineup_final
|
462 |
lineup_final = lineup_final.T
|
|
|
488 |
x += 1
|
489 |
|
490 |
if site_var1 == 'Draftkings':
|
491 |
+
portfolio.rename(columns={0: "C1", 1: "C2", 2: "W1", 3: "W2", 4: "W3", 5: "D1", 6: "D2", 7: "UTIL", 8: "G"}, inplace = True)
|
492 |
elif site_var1 == 'Fanduel':
|
493 |
+
portfolio.rename(columns={0: "C1", 1: "C2", 2: "W1", 3: "W2", 4: "D1", 5: "D2", 6: "UTIL1", 7: "UTIL2", 8: "G"}, inplace = True)
|
494 |
portfolio = portfolio.dropna()
|
495 |
portfolio = portfolio.reset_index()
|
496 |
portfolio['Lineup_num'] = portfolio['index'] + 1
|
497 |
portfolio.rename(columns={'Lineup_num': "Lineup"}, inplace = True)
|
498 |
portfolio = portfolio.set_index('Lineup')
|
499 |
portfolio = portfolio.drop(columns=['index'])
|
500 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
if site_var1 == 'Draftkings':
|
502 |
+
final_outcomes = portfolio[['C1', 'C2', 'W1', 'W2', 'W3', 'D1', 'D2', 'UTIL', 'G', 'Cost', 'Proj', 'Own']]
|
503 |
+
|
504 |
+
final_outcomes_export = pd.DataFrame()
|
505 |
+
final_outcomes_export['C1'] = final_outcomes['C1']
|
506 |
+
final_outcomes_export['C2'] = final_outcomes['C2']
|
507 |
+
final_outcomes_export['W1'] = final_outcomes['W1']
|
508 |
+
final_outcomes_export['W2'] = final_outcomes['W2']
|
509 |
+
final_outcomes_export['W3'] = final_outcomes['W3']
|
510 |
+
final_outcomes_export['D1'] = final_outcomes['D1']
|
511 |
+
final_outcomes_export['D2'] = final_outcomes['D2']
|
512 |
+
final_outcomes_export['UTIL'] = final_outcomes['UTIL']
|
513 |
+
final_outcomes_export['G'] = final_outcomes['G']
|
514 |
+
final_outcomes_export['Salary'] = final_outcomes['Cost']
|
515 |
+
final_outcomes_export['Own'] = final_outcomes['Own']
|
516 |
+
final_outcomes_export['Proj'] = final_outcomes['Proj']
|
517 |
+
|
518 |
final_outcomes_export['C1'].replace(dkid_dict, inplace=True)
|
519 |
final_outcomes_export['C2'].replace(dkid_dict, inplace=True)
|
520 |
final_outcomes_export['W1'].replace(dkid_dict, inplace=True)
|
|
|
525 |
final_outcomes_export['UTIL'].replace(dkid_dict, inplace=True)
|
526 |
final_outcomes_export['G'].replace(dkid_dict, inplace=True)
|
527 |
elif site_var1 == 'Fanduel':
|
528 |
+
final_outcomes = portfolio[['C1', 'C2', 'W1', 'W2', 'D1', 'D2', 'UTIL1', 'UTIL2', 'G', 'Cost', 'Proj', 'Own']]
|
529 |
+
|
530 |
+
final_outcomes_export = pd.DataFrame()
|
531 |
+
final_outcomes_export['C1'] = final_outcomes['C1']
|
532 |
+
final_outcomes_export['C2'] = final_outcomes['C2']
|
533 |
+
final_outcomes_export['W1'] = final_outcomes['W1']
|
534 |
+
final_outcomes_export['W2'] = final_outcomes['W2']
|
535 |
+
final_outcomes_export['D1'] = final_outcomes['D1']
|
536 |
+
final_outcomes_export['D2'] = final_outcomes['D2']
|
537 |
+
final_outcomes_export['UTIL1'] = final_outcomes['UTIL1']
|
538 |
+
final_outcomes_export['UTIL2'] = final_outcomes['UTIL2']
|
539 |
+
final_outcomes_export['G'] = final_outcomes['G']
|
540 |
+
final_outcomes_export['Salary'] = final_outcomes['Cost']
|
541 |
+
final_outcomes_export['Own'] = final_outcomes['Own']
|
542 |
+
final_outcomes_export['Proj'] = final_outcomes['Proj']
|
543 |
+
|
544 |
+
final_outcomes_export['C1'].replace(dkid_dict, inplace=True)
|
545 |
+
final_outcomes_export['C2'].replace(dkid_dict, inplace=True)
|
546 |
+
final_outcomes_export['W1'].replace(dkid_dict, inplace=True)
|
547 |
+
final_outcomes_export['W2'].replace(dkid_dict, inplace=True)
|
548 |
+
final_outcomes_export['D1'].replace(dkid_dict, inplace=True)
|
549 |
+
final_outcomes_export['D2'].replace(dkid_dict, inplace=True)
|
550 |
+
final_outcomes_export['UTIL1'].replace(dkid_dict, inplace=True)
|
551 |
+
final_outcomes_export['UTIL2'].replace(dkid_dict, inplace=True)
|
552 |
+
final_outcomes_export['G'].replace(dkid_dict, inplace=True)
|
553 |
+
|
554 |
player_freq = pd.DataFrame(np.column_stack(np.unique(portfolio.iloc[:,0:8].values, return_counts=True)),
|
555 |
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
556 |
player_freq['Freq'] = player_freq['Freq'].astype(int)
|
|
|
571 |
st.download_button(
|
572 |
label="Export Optimals",
|
573 |
data=convert_df_to_csv(final_outcomes_export),
|
574 |
+
file_name='NHL_optimals_export.csv',
|
575 |
mime='text/csv',
|
576 |
)
|
577 |
with freq_container:
|