def get_splits_for_batter(rguru_id): batter_name = get_player.name_from_id(rguru_id) pitcher_ids = get_pitchers(rguru_id) # for pid in pitcher_ids: # print get_player.name_from_id(pid, 'p') l, r = get_ratio(pitcher_ids) print "Pitchers faced by {}".format(batter_name) print "Lefties ({:.2f}%) | Righties ({:.2f}%)".format(l*100, r*100)
def get_splits_for_batter(rguru_id): batter_name = get_player.name_from_id(rguru_id) pitcher_ids = get_pitchers(rguru_id) # for pid in pitcher_ids: # print get_player.name_from_id(pid, 'p') l, r = get_ratio(pitcher_ids) print "Pitchers faced by {}".format(batter_name) print "Lefties ({:.2f}%) | Righties ({:.2f}%)".format(l * 100, r * 100)
def make_plots(self): for player in self.plots: if len(player.points) == 0: name = get_player.name_from_id(player.id_) if name is None: print "No record for player with id: {}".format(player.id_) else: print "No scoring data for player: {} (id={})".format(name, player.id_) else: player.plot_hist(bins=50)
def get_all_splits(sample_lim=50): """ Will get L/R splits for all batters at bats > sample_lim. :return: """ bat_ids = get_batter_ids(sample_lim) pitcher_ids = get_pitchers_many(bat_ids) batter_ratios = [[get_player.name_from_id(id_), '{:.2f}'.format(l*100), '{:.2f}'.format(r*100)] for id_, l, r in sorted(get_all_ratios(pitcher_ids), key=lambda x: x[1], reverse=True)] print tabulate.tabulate(batter_ratios, ['Player', 'vs L', 'vs R'], 'fancy_grid')
def get_all_splits(sample_lim=50): """ Will get L/R splits for all batters at bats > sample_lim. :return: """ bat_ids = get_batter_ids(sample_lim) pitcher_ids = get_pitchers_many(bat_ids) batter_ratios = [[ get_player.name_from_id(id_), '{:.2f}'.format(l * 100), '{:.2f}'.format(r * 100) ] for id_, l, r in sorted( get_all_ratios(pitcher_ids), key=lambda x: x[1], reverse=True)] print tabulate.tabulate(batter_ratios, ['Player', 'vs L', 'vs R'], 'fancy_grid')
def get_name(self): return get_player.name_from_id(self.id_)