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

Adds DataFrameLineupExporter class to lineup_exporter.py #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pydfs_lineup_optimizer/lineup_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ def export(self, filename, render_func=None):
lineup_writer.writerow(row)


class DataFrameLineupExporter(LineupExporter):
def export(self, render_func=None):
rows = []
try:
for index, lineup in enumerate(self.lineups):
if index == 0:
pass
row = [(render_func or self.render_player)(player) for player in lineup.lineup]
row.append(str(lineup.salary_costs))
row.append(str(lineup.fantasy_points_projection))
rows.append(row)
import pandas as pd
return pd.DataFrame(rows)
except (ImportError, ModuleNotFoundError):
return rows


class FantasyDraftCSVLineupExporter(LineupExporter):
def export(self, filename, render_func=None):
if not self.lineups:
Expand Down