Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import csv def player_stats(csv_data_file): # Returns a dictionary that maps each player name to a dictionary of statistics' players_dict= {} header = [] with open(csv_data_file)

import csv

def player_stats(csv_data_file): # Returns a dictionary that maps each player name to a dictionary of statistics' players_dict= {} header = [] with open(csv_data_file) as csvfile: csvReader = csv.reader(csvfile, delimiter=',') row_number = 1 for row in csvReader: rowDict = {} if row_number ==1: header = row else: for i in range(1,len(row)): rowDict[header[i]] = row[i] players_dict[row[0]] = rowDict row_number +=1

return players_dict

players1 = player_stats('Quarterbacks.csv')

Using the function above for a csv file, write loops to retrieve data in the following ways, indicated on the comments of the initial Python file. Please see complete testing results of the program below.

For Quarterback data:

# compute average number of touch downs

# find player with maximum number of completions

# find players with more than 5 touch downs

>>>> (Outputs for Quarterback data)

** Average number of touch downs: 3.15

** Player with most completions: Aaron Rodgers with 107.0 completions

** Players with more than 5 touch downs: ['Drew Brees', 'Tom Brady', 'Matthew Stafford', 'Alex Smith', 'Blake Bortles', 'Aaron Rodgers', 'Derek Carr', 'Trevor Siemian']

For NBA data:

# compute average number of PPG

# find player with minimum number of FT%

# find players for team CHI

>>>>>> (Outputs for NBA data)

** Average number of PPG's: 16.31

** Player with minimum FT%: Andre Drummond with 0.386 FT%

** Players on Team CHI: ['Nikola Mirotic', 'Jimmy Butler', 'Robin Lopez']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What does Security First do?

Answered: 1 week ago

Question

Know the components of a position description

Answered: 1 week ago

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago