pydfs-lineup-optimizer icon indicating copy to clipboard operation
pydfs-lineup-optimizer copied to clipboard

Player Usage Breakdown

Open austinjohnson opened this issue 4 years ago • 1 comments

Is there a way to get a breakdown from lineups generated for example if I were to generate 10,000 lineups for a given slate is there a way I can get a csv file with a breakdown of every player used, his position, and how many times he was used relative to how many lineups were generated?

Example: I have a 6 game slate and I generate 10,000 lineups the csv file would look like this

Name Pos Usage% Russell Westbrook PG 43% Kobe Bryant SF 56% Andre Drummond C 65%

For showdown

Name Pos Usage% Russell Westbrook CPTN 12% Kobe Bryant CPTN 35% Andre Drummond FLEX 65%

Is there a quick way to do this or would this need to be a feature? I think this is useful because you can find the number of times a player was used to create an optimal lineup relative to his ownership %.

austinjohnson avatar Jan 20 '21 23:01 austinjohnson

The simplest way to do this is to use the CSVLineupExporter and then read the data into an analysis library, such as pandas. You can also do these calculations in pure python by iterating over the csv file and creating a dict where the key is a tuple of the player information and the value is a tuple of the ownership numbers. If you know pandas, however, it will be easier to use the exporter or the method below to directly generate a dataframe.

import pandas as pd

selected_players = []
for l in lineups:
    for p in l.lineup:
        selected_players.append(p._player.__dict__.items())
        
df = pd.DataFrame(selected_players)

You can then aggregate by player name, etc. using standard pandas functions.

sansbacon avatar Jan 29 '21 05:01 sansbacon