コード例 #1
0
def run_pipeline():
	pipeline_in = util.get_fd_pipe_in_fname()
	pipeline_out = util.get_fd_pipe_out_fname()

	if os.path.exists(pipeline_out):
		f = open(pipeline_out, 'r')
		data = json.loads(f.read())
		f.close()
		return data

	player_mapping = {}

	dataframe = pandas.read_csv(pipeline_in)
	nrows = len(dataframe)

	for c in range(nrows):
		curr_player = ' '.join([dataframe['First Name'][c], dataframe['Last Name'][c]])
		fanduel_data = {}
		fanduel_data['salary'] = dataframe['Salary'][c]
		fanduel_data['FPPG'] = dataframe['FPPG'][c]
		player_mapping[curr_player] = fanduel_data

	data = json.dumps(player_mapping, sort_keys=True, indent=4)
	f = open(pipeline_out, 'w+')
	f.write(data)
	f.close()
	return data
コード例 #2
0
import daily_lineup_pipeline
from util import get_curr_date, Player, Team, Game, parse_team_depth, parse_games, get_curr_time, load_config
import util
from query_engine import PlayerQueryEngine
import json
import datetime
import os
import datetime


"""
GLOBAL DATA LOADING
"""

fanduel_data_path = util.get_fd_pipe_out_fname()
fanduel_data = json.loads(open(fanduel_data_path, 'r').read())

player_query_engine = PlayerQueryEngine()

def player_stats_perspective(player):
	name = player.get_name()
	player.set_property('last_5_games', player_query_engine.get_last_n_stats(name, n=5))
	if len(player.get_property('last_5_games')) > 0:
		player.set_property('last_5_games_avg', player_query_engine.get_last_n_averaged_stats(name, n=5))
		player.set_property('last_5_games_std', player_query_engine.get_last_n_stats_std(name, n=5))

	# @TODO: Instead of repeating query, just make this query first and choose bottom half of the data
	# and compute the average and std manually that way
	player.set_property('last_10_games', player_query_engine.get_last_n_stats(name, n=10))
	if player.get_property('last_10_games') and len(player.get_property('last_10_games')) > 0:
		player.set_property('last_10_games_avg', player_query_engine.get_last_n_averaged_stats(name, n=10))