Question: In the next cell, we load a dataset compiled by the Daily Cal about UC Berkeley (where this course was created). It includes information on

In the next cell, we load a dataset compiled by the Daily Cal about UC Berkeley (where this course was created). It includes information on faculty, their departments, their positions, and their gross salaries in 2015. profs = Table.read_table("faculty.csv").where("year", are.equal_to(2015)) .drop("year", "title") .relabeled("title_category", "position") profs We want to use this table to generate arrays with the names of each professor in each department. Question 1 Set prof_names to a table with two columns. The first column should be called "department" and have the name of every department once, and the second column should be called "faculty" and contain an array of the names of all faculty members in that department. Hint: Think about how group works: it collects values into an array and then applies a function to that array. We have defined two functions below for you, and you will need to use one of them in your call to group. If you're not sure which to use, try experimenting with both! # Pick between the two functions defined below def identity(array): return array def first(array): return array.item() prof_names = prof_names Question 2 At the moment, the name column of profs is sorted by last name. Would the arrays you generated in the previous part be the same as if we had sorted by first name instead? When we say that two arrays are the same, we mean that they contain the same number of elements and the elements in the corresponding positions are identical. Explain your answer. If you feel you need to make certain assumptions about the data, feel free to state them in your response. Write your answer here, replacing this text. Question 3 Set biggest_range_dept to the name of the department with the largest salary range, where range is defined as the difference between the lowest and highest salaries in the department. Hint First you'll need to define a new function salary_range which takes in an array of salaries and returns the salary range of the corresponding department. Think about what functions we have discussed can combine and give you this range. Then, set department_ranges to a table containing the names and salary ranges of each department. In the next cell, we load a dataset compiled by the Daily Cal about UC Berkeley (where this course was created). It includes information on faculty, their departments, their positions, and their gross salaries in 2015. profs = Table.read_table("faculty.csv").where("year", are.equal_to(2015)) .drop("year", "title") .relabeled("title_category", "position") profs We want to use this table to generate arrays with the names of each professor in each department. Question 1 Set prof_names to a table with two columns. The first column should be called "department" and have the name of every department once, and the second column should be called "faculty" and contain an array of the names of all faculty members in that department. Hint: Think about how group works: it collects values into an array and then applies a function to that array. We have defined two functions below for you, and you will need to use one of them in your call to group. If you're not sure which to use, try experimenting with both! # Pick between the two functions defined below def identity(array): return array def first(array): return array.item() prof_names = prof_names Question 2 At the moment, the name column of profs is sorted by last name. Would the arrays you generated in the previous part be the same as if we had sorted by first name instead? When we say that two arrays are the same, we mean that they contain the same number of elements and the elements in the corresponding positions are identical. Explain your answer. If you feel you need to make certain assumptions about the data, feel free to state them in your response. Write your answer here, replacing this text. Question 3 Set biggest_range_dept to the name of the department with the largest salary range, where range is defined as the difference between the lowest and highest salaries in the department. Hint First you'll need to define a new function salary_range which takes in an array of salaries and returns the salary range of the corresponding department. Think about what functions we have discussed can combine and give you this range. Then, set department_ranges to a table containing the names and salary ranges of each department
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
