Hint The relevant column labels are Cerebrovascular Disease Stroke and Chronic

Hint the relevant column labels are cerebrovascular

This preview shows page 6 - 10 out of 11 pages.

Hint:The relevant column labels are "Cerebrovascular Disease (Stroke)" and "Chronic LiverDisease and Cirrhosis"In [25]:distributions.select("Year","Cerebrovascular Disease (Stroke)","Chronic Liver Diseas# Don't change the code below this comment.plt.title("% of total deaths / disease per year")plt.xlabel("% of total deaths")Out[25]:Text(0.5, 0,'% of total deaths')6
Background image
1.22. Faculty salariesIn the next cell, we load a dataset created by theDaily Calwhich contains Berkeley faculty, theirdepartments, their positions, and their gross salaries in 2015.In [26]:raw_profs=Table.read_table("faculty.csv").where("year", are.equal_to(2015)).drop("yeprofs=raw_profs.relabel("title_category","position")profsOut[26]:name| department| position| gross_salaryCYNTHIA ABAN| South & Southeast Asian Studies | lecturer| 64450PIETER ABBEEL| Computer Science| associate professor | 184998SALLY ABEL| Law| lecturer| 3466ELIZABETH ABEL| English| professor| 138775DOR ABRAHAMSON| Education| associate professor | 100300KATHRYN ABRAMS| Law| professor| 319693BARBARA ABRAMS| Public Health| professor| 191162SARAH ACCOMAZZO | Social Welfare| lecturer| 14779CHARISMA ACEY| City and Regional Planning| assistant professor | 101567DAVID ACKERLY| Biology| professor| 182288... (2049 rows omitted)We want to use this table to generate arrays with the names of each professor in each depart-ment.7
Background image
Question 1.Setprof_namesto a table with two columns. The first column should be calleddepartmentand have the name of every department once, and the second column should be calledfacultyand contain anarrayof the names of all faculty members in that department.Hint:Think about howgroupworks: it collects values into an array and then applies a functionto that array. We have defined two functions below for you, and you will need to use one of themin your call togroup.In [30]:# Pick one of the two functions defined below in your call to group.defidentity(array):returnarraydeffirst(array):returnarray.item(0)In [35]:prof_names=profs.drop("position","gross_salary").group("department", identity).relabprof_namesOut[35]:department| facultyAfrican American Studies| ['AYA DE LEON' 'CHIYUMA ELLIOTT' 'NIKAgricultural and Resource Economics and Policy | ['MAXIMILIAN AUFFHAMMER' 'CHARLES GIBAnthroplogy| ['SABRINA AGARWAL' 'STANLEY BRANDES''...Architecture| ['MARK ANDERSON' 'JACOB ATHERTON' 'WIArt History| ['DILIANA ANGELOVA' 'PATRICIA BERGER'Art Practice| ['ALLAN DESOUZA' 'AIDA GAMEZ' 'RANDYAstronomy| ['GIBOR BASRI' 'STEVEN BECKWITH' 'LEOBioengineering| ['ADAM ARKIN' 'IRINA CONBOY' 'STEVENBiology| ['DAVID ACKERLY' 'HILLEL ADESNIK' 'KEBuddhist Studies| ['JANN RONIS']... (61 rows omitted)In [36]:_=ok.grade('q2_1')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passedQuestion 2.At the moment, thenamecolumn is sorted by last name. Would the arrays yougenerated in the previous part be the same if we had sorted by first name instead before generatingthem? Two arrays are thesameif they contain the same number of elements and the elements8
Background image
located at corresponding indexes in the two arrays are identical. Explain your answer. If you feelyou need to make certain assumptions about the data, feel free to state them in your response.
Background image
Image of page 10

You've reached the end of your free preview.

Want to read all 11 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes