Closed BenikaH closed 4 years ago
how does your export look?, cause mine uploads fine
The players are printed like this;
Trae Young(42351-84671)
Is yours that way as well?
can I see the code your using to print
for lineup in lineups:
print(lineup)
exporter = CSVLineupExporter(lineups)
exporter.export('/Users/BH/Downloads/nba-rand-1.csv')
for lineup in lineups: print(lineup) exporter = CSVLineupExporter(lineups) exporter.export('/Users/BH/Downloads/nba-rand-1.csv', lambda p: p.id)
Try that and let me know if that worked
Ok I’ll try when I get home. Yours doesn’t export that way?
no mine just exports id
No, that gives an error.
TypeError: __init__() takes 2 positional arguments but 3 were given
exporter.export('/Users/BH/Downloads/nba-rand-1.csv', p.id)
see what that does
I'll check mine at home in an hour for you
That is odd.
what is odd?
i noticed you had a question about grouping players but i cant seem to get that right... Have you and gotten that to work?
Oh, its odd that its printing the names at all. Maybe because I'm getting the players by name. Sure, go to this post, Sansbacon offered a great solution for the two scenarios I wanted. https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/105#issuecomment-540873508
i tryed adding the code but its not working for me
`from pydfs_lineup_optimizer import get_optimizer, Site, Sport, CSVLineupExporter optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASKETBALL) optimizer.load_players_from_csv('/Users/bc/Downloads/DKSalaries (8).csv')
optimizer.set_teams_max_exposure({team: 0.45 for team in optimizer.available_teams})
optimizer.set_max_repeating_players(5)
lineups=[]
player_groups = [['James Harden', 'C.J. McCollum','Hassan Whiteside' ], ['James Harden','Russell Westbrook', 'Derrick Favors']]#,['Lou Williams','Jayson Tatum', 'Montrezl Harrell']] n = 20
for group in player_groups: for player_name in group: optimizer.add_player_to_lineup(optimizer.get_player_by_name(player_name)) for lineup in optimizer.optimize(n, randomness=True): lineups.append(lineup) for player_name in group: optimizer.remove_player_from_lineup(optimizer.get_player_by_name(player_name))
for lineup in lineups: print(lineup)
exporter = CSVLineupExporter(lineups)`
how does your python code look when you run it, i tryed all kinds of ways to use that
Try that above. I started with NFL and then used the same approach with NBA.
okay testing now
seems to not like me
for group in player_groups:
...
File "
^
IndentationError: expected an indented block
for group in player_groups: ... for player_name in group: ... optimizer.add_player_to_lineup(optimizer.get_player_by_name(player_name)
Now, that I'm thinking about it. It may be because I'm getting the player by the name and printing it that way. I'll have to adjust it then because FD does not like it the way it prints out.
That's because of the code marks. ` from pydfs_lineup_optimizer import get_optimizer, Site, Sport, CSVLineupExporter optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASKETBALL) optimizer.load_players_from_csv('/Users/bc/Downloads/DKSalaries (8).csv')
optimizer.set_teams_max_exposure({team: 0.45 for team in optimizer.available_teams})
optimizer.set_max_repeating_players(5)
lineups=[]
player_groups = [['James Harden', 'C.J. McCollum','Hassan Whiteside' ], ['James Harden','Russell Westbrook', 'Derrick Favors']]#,['Lou Williams','Jayson Tatum', 'Montrezl Harrell']] n = 20
for group in player_groups: for player_name in group: optimizer.add_player_to_lineup(optimizer.get_player_by_name(player_name)) for lineup in optimizer.optimize(n, randomness=True): lineups.append(lineup) for player_name in group: optimizer.remove_player_from_lineup(optimizer.get_player_by_name(player_name))
for lineup in lineups: print(lineup)
exporter = CSVLineupExporter(lineups)
`
i must of gotten something to work but now i get
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pydfs_lineup_optimizer/lineup_optimizer.py", line 305, in remove_player_from_lineup self._lineup.remove(player) ValueError: list.remove(x): x not in list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Fanduel.py", line 31, in
Check the player groups you have and the csv you're using. Make sure the player is there in the csv.
can you check over the python script? i have the guys in the import file
import pulp from pulp.solvers import COIN_CMD from pydfs_lineup_optimizer import get_optimizer, Site, Sport,CSVLineupExporter from pydfs_lineup_optimizer.solvers.pulp_solver import PuLPSolver import time
start_time = time.time()
class COIN_CMDSolver(PuLPSolver): LP_SOLVER = COIN_CMD(msg=0)
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL, solver=COIN_CMDSolver) optimizer.load_players_from_csv('/root/Downloads/players-list.csv')
optimizer.set_teams_max_exposure({team: 0.45 for team in optimizer.available_teams})
player_groups = [['John Collins', 'Trae Young','Cam Reddish' ], ['Tristan Thompson','Kevin Love', 'Collin Sexton'],['Dwight Powell','Luka Doncic', 'Tim Hardaway']] n = 20
for group in player_groups: for player_name in group: optimizer.add_player_to_lineup(optimizer.get_player_by_name(player_name)) for lineup in optimizer.optimize(n, randomness=True): lineups.append(lineup) for player_name in group: optimizer.remove_player_from_lineup(optimizer.get_player_by_name(player_name))
for lineup in lineups: print(lineup)
Let me check, hold on.
or i could be thinking this wrong i want groups of players together during optimizing
i get this now pydfs_lineup_optimizer.exceptions.LineupOptimizerException: You're already select all C's
i got it too work a little but its only using the first group
Oh yeah, remove one of the Centers and re-run.
You're thinking of it correctly. I don't have all of the solvers installed so I had to install them.
finally got it working
Good. How does your csv look? Name and ID or just IDs?
PG | PG | SG | SG | SF | SF | PF | PF | C | Budget | FPPG |
---|---|---|---|---|---|---|---|---|---|---|
42769-84671 | 42769-84667 | 42769-19067 | 42769-15595 | 42769-110339 | 42769-80809 | 42769-9874 | 42769-66236 | 42769-14501 | 59800 | 297.183 |
42769-84671 | 42769-84667 | 42769-19067 | 42769-15595 | 42769-110339 | 42769-15904 | 42769-9874 | 42769-66236 | 42769-14501 | 59800 | 293.619 |
i am on fanduel by the way
i can check on draftkings if thats what your useing to make sure
draftkings sould be like this
PG | SG | SF | PF | C | G | F | UTIL |
---|---|---|---|---|---|---|---|
Donte DiVincenzo (14151787) | Spencer Dinwiddie (14151732) | Khris Middleton (14151721) | Derrick Favors (14151728) | Brook Lopez (14151764) | Kyrie Irving (14151707) | Wilson Chandler (14151841) | Giannis Antetokounmpo (14151692) |
for lineup in lineups: print(lineup) exporter = CSVLineupExporter(lineups) exporter.export('/root/result.csv', lambda p: p.id)
Wow, so why is mine doing the Name and ID like that? What line do have for exporter?
change the directory
let me know what you get
Now it works! I must have had an old version cached. I re-installed 2.7.0 and ignored old versions. Then I put in the lambda p: p.id
and it worked. Before, it would throw a Type error. Thanks.
your welcome and thanks for the help also
No problem! I want to ask you about COINMD solver. I'll send outside of this thread.
anytime
Was the FanDuel ID format changed in the CSVLineupExporter in 2.7.0? Still can't upload the lineups generated using 2.7. Gives an Invalid entry error.
I'm thinking its because the ID is no longer Name(ID) but it is now ID:Name. Any thoughts here?