Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player Usage Breakdown #235

Open
austinjohnson opened this issue Jan 20, 2021 · 1 comment · May be fixed by #241
Open

Player Usage Breakdown #235

austinjohnson opened this issue Jan 20, 2021 · 1 comment · May be fixed by #241

Comments

@austinjohnson
Copy link

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 %.

@sansbacon
Copy link
Contributor

sansbacon commented Jan 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants