Line graph of games played for one player over time, separated based on team Next, you’ll build a…
Line graph of games played for one player over time, separated based on team Next, you’ll build a more complex graph based on the one that you previously produced. Graph the number of games played per year for a specific player, but plot a separate line for each team that they played for.
Follow the same strategy as in 3a: To begin with, go ahead and “hardcode” in a certain player’s id. Once you have a graph that works, let the user pick between either:
c) entering the player id themselves OR
d) generating a graph for a randomly selected player You may assume that the user will enter a correct player id.Existing code for runs over all teams over time graph and classes
def player_games(data, playerid):
line_data = get_matching_rows(data,BD.player_id,playerid)
index = 0
x_axis = []
y_axis = []
while index < len(line_data):
x_axis.append(line_data[index][0])
y_axis.append(line_data[index][5])
index += 1
plt.plot (x_axis,y_axis)
plt.xlabel(“Years”)
plt.ylabel(“Games”)
plt.show()
class BD:
year = 0
player_id = 1
first_name = 2
last_name = 3
team_name = 4
games = 5
at_bats = 6
runs = 7
hits = 8
doubles = 9
triples = 10
home_runs = 11
rbi = 12
walks = 13
hbp = 14
stolen_bases = 15
caught_stealing = 16
strike_outs = 17
sac_flies = 18
position = 19