N j c s c 4 ro o playername salary kobe bryant

• Homework Help
• ConstableMonkey7683
• 16
• 100% (6) 6 out of 6 people found this document helpful

This preview shows page 12 - 16 out of 16 pages.

N J C S C .. (4 ro o PlayerName Salary Kobe Bryant 23500000 Amar'e Stoudemire 23410988 Joe Johnson 23180790 ... (489 rows omitted)
7/1/2018 lab05_solutions In : def histograms(t): ages = t.column('Age') salaries = t.column('Salary') age_bins = np.arange(min(ages), max(ages) + 2, 1) #SOLUTION salary_bins = np.arange(min(salaries), max(salaries) + 2000000, 1000000) #SOLUTION t.hist('Age', bins=age_bins, unit='year') t.hist('Salary', bins=salary_bins, unit='\$') return age_bins # Keep this statement so that your work can be checked histograms(full_data) print('Two histograms should be displayed below') In [ ]: _ = ok.grade('q3_1') # Warning: Charts will be displayed while running this test Question 3.2 . Create a function called compute_statistics that takes a Table containing ages and salaries and: Two histograms should be displayed below
13/16 You can call your histograms function to draw the histograms!
7/1/2018 lab05_solutions 14/16 In : def compute_statistics(age_and_salary_data): histograms(age_and_salary_data) #SOLUTION age = age_and_salary_data.column("Age") #SOLUTION salary = age_and_salary_data.column("Salary") #SOLUTION return make_array(np.mean(age), np.mean(salary)) #SOLUTION full_stats = compute_statistics(full_data) In [ ]: _ = ok.grade('q3_2') # Warning: Charts will be displayed while running this test Convenience sampling One sampling methodology, which is generally a bad idea , is to choose players who are somehow convenient to sample. For example, you might choose players from one team that's near your house, since it's easier to survey them. This is called, somewhat pejoratively, convenience sampling . Suppose you survey only relatively new players with ages less than 22. (The more experienced players didn't bother to answer your surveys about their salaries.) Question 3.3 Assign convenience_sample_data to a subset of full_data that contains only the rows for players under the age of 22. In [ ]: convenience_sample = full_data.where("Age", are.below(22)) #SOLUTION convenience_sample In [ ]: _ = ok.grade('q3_3')
7/1/2018 lab05_solutions Question 3.4 Assign convenience_stats to a list of the average age and average salary of your convenience sample, using the compute_statistics function. .
15/16
• • • 