Question: Calculating baseball statistics in a file The Lahman Baseball Database is a comprehensive database of Major League baseball statistics. The journalist Sean Lahman provides all
Calculating baseball statistics in a file
The Lahman Baseball Database is a comprehensive database of Major League baseball statistics. The journalist Sean Lahman provides all of this data freely to the public. We will make use of some of his data in this assignment.
| playerID | yearID | stint | teamID | lgID | G | AB | R | H | 2B | 3B | HR | RBI | SB | CS | BB | SO | IBB | HBP | SH | SF | GIDP |
| abercda01 | 1871 | 1 | TRO | NA | 1 | 4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||||
| addybo01 | 1871 | 1 | RC1 | NA | 25 | 118 | 30 | 32 | 6 | 0 | 0 | 13 | 8 | 1 | 4 | 0 | |||||
| allisar01 | 1871 | 1 | CL1 | NA | 29 | 137 | 28 | 40 | 4 | 5 | 0 | 19 | 3 | 1 | 2 | 5 | |||||
| allisdo01 | 1871 | 1 | WS3 | NA | 27 | 133 | 28 | 44 | 10 | 2 | 2 | 27 | 1 | 1 | 0 | 2 | |||||
| ansonca01 | 1871 | 1 | RC1 | NA | 25 | 120 | 29 | 39 | 11 | 3 | 0 | 16 | 6 | 2 | 2 | 1 | |||||
| armstbo01 | 1871 | 1 | FW1 | NA | 12 | 49 | 9 | 11 | 2 | 1 | 0 | 5 | 0 | 1 | 0 | 1 | |||||
| barkeal01 | 1871 | 1 | RC1 | NA | 1 | 4 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 1 | 0 | |||||
| barnero01 | 1871 | 1 | BS1 | NA | 31 | 157 | 66 | 63 | 10 | 9 | 0 | 34 | 11 | 6 | 13 | 1 | |||||
| barrebi01 | 1871 | 1 | FW1 | NA | 1 | 5 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | |||||
| barrofr01 | 1871 | 1 | BS1 | NA | 18 | 86 | 13 | 13 | 2 | 1 | 0 | 11 | 1 | 0 | 0 | 0 | |||||
| bassjo01 | 1871 | 1 | CL1 | NA | 22 | 89 | 18 | 27 | 1 | 10 | 3 | 18 | 0 | 1 | 3 | 4 | |||||
| battijo01 | 1871 | 1 | CL1 | NA | 1 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
This is a part of the database, i cannot import all of it since it is too big
Please fill in the ??? in Python.
Your submission should include the following variables defined correctly:
career_rbis
max_rbis
max_player
career_rbis = { } # Open the file. Call it batting_file and the file name 'batting.csv'. ??? # Read the data from the file using a `for` loop. for line in batting_file.???: line = line.strip() # remove whitespace from the line values = ??? # split the line by commas ',' if values[ 0 ] == 'playerID': continue # skip the header line batter_id = ??? # get the batter_id rbis = ??? # get the RBIs # ignore non-digit RBIs ??? # check if batter_id is in career_rbis if batter_id not in career_rbis: # add it ??? else: # add the RBIs career_rbis[ batter_id ] = ??? # Find the player with the maximum RBIs. This will probably take # several lines of code and some serious thought on your part. Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
