pydfs-lineup-optimizer
pydfs-lineup-optimizer copied to clipboard
Help with creating a seperate data csv
@sansbacon You helped me create something like this before but this is a altered version and doesnt work so im testing a csv i made with some data but i want it to weed out a bunch of players with the player names and the POSS COLUMN
import pandas as pd
csv_filepath = '/root/NBA/2Slate/poss.csv'
cdf = pd.read_csv(csv_filepath)
#set this to whatever you want the correlation cutoff to be
correlation_threshold = 230
for i in range(len(cdf)):
if cdf['POSS'].iloc[i] <= correlation_threshold:
negative_corr_players = (cdf['PLAYER'].iloc[i],cdf['POSS'].iloc[i])
group = PlayersGroup([optimizer.get_player_by_name(name) for name in (negative_corr_players)])
optimizer.add_players_group(group)
here is the csv data
PLAYER | TEAM | AGE | GP | W | L | MIN | OFFRTG | DEFRTG | NETRTG | AST% | AST/TO | AST RATIO | OREB% | DREB% | REB% | TO RATIO | EFG% | TS% | USG% | PACE | PIE | POSS |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Anthony Edwards | MIN | 20 | 5 | 1 | 4 | 38 | 105.4 | 114.8 | -9.4 | 16.5 | 0.72 | 12.1 | 4.3 | 14.1 | 8.7 | 16.8 | 51.1 | 54.3 | 27.9 | 99.07 | 10 | 392 |
D'Angelo Russell | MIN | 25 | 5 | 1 | 4 | 34.8 | 105.7 | 105.5 | 0.2 | 31.7 | 3.3 | 23.2 | 0 | 8.3 | 4 | 7 | 51.1 | 54.2 | 25.3 | 100.81 | 12.7 | 368 |
Jaden McDaniels | MIN | 21 | 5 | 1 | 4 | 25.8 | 100.4 | 111.8 | -11.5 | 7.1 | 2 | 10.7 | 6.9 | 8.9 | 7.8 | 5.4 | 40.7 | 43.7 | 15.5 | 102.69 | 2.6 | 274 |
Jake Layman | MIN | 27 | 2 | 1 | 1 | 4.5 | 90.9 | 90.5 | 0.4 | 0 | 0 | 0 | 0 | 7.1 | 3.8 | 20 | 37.5 | 37.5 | 18.5 | 115.74 | -3 | 22 |
i want it to remove players with a threshold of like 250 in the POSS column, i can do this in the playerlist but i wanna keep them in the list and just changing the threshold
I tryed this import pandas as pd
csv_filepath = '/root/NBA/2Slate/poss.csv'
cdf = pd.read_csv(csv_filepath)
#set this to whatever you want the correlation cutoff to be
correlation_threshold = 230
for i in range(len(cdf)):
if cdf['POSS'].iloc[i] <= correlation_threshold:
negative_corr_players = (cdf['PLAYER'].iloc[i])
group = PlayersGroup([optimizer.get_player_by_name(name) for name in (negative_corr_players)])
optimizer.add_players_group(group)
but i got
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pydfs_lineup_optimizer/lineup_optimizer.py", line 417, in optimize solved_variables = solver.solve() File "/usr/local/lib/python3.7/dist-packages/pydfs_lineup_optimizer/solvers/pulp_solver.py", line 58, in solve raise SolverInfeasibleSolutionException(invalid_constraints) pydfs_lineup_optimizer.solvers.exceptions.SolverInfeasibleSolutionException: ['positions_PF', 'positions_C', 'positions_PF_SF', 'positions_C_PF', 'positions_C_PF_SF', 'max_from_one_team_MIN', 'max_from_one_team_OKC', '_C1', '_C4', '_C5', '_C9', '_C13', '_C19', '_C23', '_C27', '_C31', '_C51', '_C59', '_C67', '_C71', '_C75', '_C77', '_C79', '_C81', '_C87', '_C88', '_C89', '_C90', '_C91', '_C92', '_C93', '_C94', '_C95', '_C96', '_C97', 'locked_players']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Fanduel2Finish2.py", line 116, in