Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python jupyter error help. I don't know where I did wrong, need to debug. 2. San Francisco City Employee Salaries This exercise is designed to

python jupyter error help. I don't know where I did wrong, need to debug.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

2. San Francisco City Employee Salaries This exercise is designed to give you practice with using the Table methods and Here is a link to the Python Reference in case you need a quick refresher. The Table Function Visualizer may also be a helpful tool. Run the cell below to view a demo on how you can use pivot on a table. (Thank you to past staff Divyesh Chotai!) \# Don't worry about what this code does! It simply embeds a YouTube video into a code cell. from IPython.display import YouTubeVideo YouTubeVideo("4bzXo8eKLAg") The data source we will use within this portion of the homework is publicly provided by the City of San Francisco. We have filtered it to retain just the relevant columns and restricted the data to the calendar year 2019. Run the following cell to load our data into a table called full_sf . (44520 rows omitted) The table has one row for each of the 44,525 San Francisco government employees in 2019. The first four columns describe the employee's job. For example, the employee in the third row of the table had a job called "IS Business Analyst-Senior". We will call this the employee's position or job title. The job was in a Job Family called Information Systems (hence the IS in the job title), and was in the Adult Probation Department that is part of the Public Protection Organization Group of the government. You will mostly be working with the Job column. The next three columns contain the dollar amounts paid to the employee in the calendar year 2019 for salary, overtime, and benefits. Note that an employee's salary does not nclude their overtime earnings. The last column contains the total compensation paid to the employee. It is the sum of the previous three columns: TotalCompensation=Salary+Overtime+Benefits For this homework, we will be using the following columns: 1. Organization Group: A group of departments. For example, the Public Protection Org. Group includes departments such as the Police, Fire, Adult Protection, District Attorney, etc. 2. Department: The primary organizational unit used by the City and County of San Francisco. 3. Job: The specific position that a given worker fills. 4. Total Compensation: The sum of a worker's salary, overtime, and benefits in 2019. Run the following cell to select the relevant columns and create a new table named sf. ff= full_sf.select("Job", "Department", "Organization Group", "Total Compensation") f. show (5) We want to use this table to generate arrays with the job titles of the members of each Organization Group. Question 1. Set job_titles to a table with two columns. The first column should be called Organization Group and have the name of every "Organization Group" once, and the second column should be called Jobs with each row in that second column containing an array of the names of all the job titles within that "Organization Group". Don't worry if there are multiple of the same job titles. (9 Points) Hint 1: Think about how 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. Hint 2: You might need to rename one of the columns. 43]: \# Pick one of the two functions defined below in your call to group. def first_item(array): '"'Returns the first item'" return array.item( () def full_array (array): "'Returns the array that is passed through'"' return array \# Make a call to group using one of the functions above when you define job_titles job_titles = sf.select('Organization Group' , 'Job').group('Organization Group') job_titles 427: 42]: grader.check("q2_1") 42]: q2_1results:q2_1-1result: Test case passed! q2_1-2result: Test case passed! q2_1-3result: Test case passed! q2_1 - 4 result: Trying: np.asarray(job_titles.labels).item(1) == "Jobs" Expecting: True Line 2, in q2_13 Failed example: np.asarray(job_titles.labels).item(1) == "Jobs" Expected: True Got: False 2. San Francisco City Employee Salaries This exercise is designed to give you practice with using the Table methods and Here is a link to the Python Reference in case you need a quick refresher. The Table Function Visualizer may also be a helpful tool. Run the cell below to view a demo on how you can use pivot on a table. (Thank you to past staff Divyesh Chotai!) \# Don't worry about what this code does! It simply embeds a YouTube video into a code cell. from IPython.display import YouTubeVideo YouTubeVideo("4bzXo8eKLAg") The data source we will use within this portion of the homework is publicly provided by the City of San Francisco. We have filtered it to retain just the relevant columns and restricted the data to the calendar year 2019. Run the following cell to load our data into a table called full_sf . (44520 rows omitted) The table has one row for each of the 44,525 San Francisco government employees in 2019. The first four columns describe the employee's job. For example, the employee in the third row of the table had a job called "IS Business Analyst-Senior". We will call this the employee's position or job title. The job was in a Job Family called Information Systems (hence the IS in the job title), and was in the Adult Probation Department that is part of the Public Protection Organization Group of the government. You will mostly be working with the Job column. The next three columns contain the dollar amounts paid to the employee in the calendar year 2019 for salary, overtime, and benefits. Note that an employee's salary does not nclude their overtime earnings. The last column contains the total compensation paid to the employee. It is the sum of the previous three columns: TotalCompensation=Salary+Overtime+Benefits For this homework, we will be using the following columns: 1. Organization Group: A group of departments. For example, the Public Protection Org. Group includes departments such as the Police, Fire, Adult Protection, District Attorney, etc. 2. Department: The primary organizational unit used by the City and County of San Francisco. 3. Job: The specific position that a given worker fills. 4. Total Compensation: The sum of a worker's salary, overtime, and benefits in 2019. Run the following cell to select the relevant columns and create a new table named sf. ff= full_sf.select("Job", "Department", "Organization Group", "Total Compensation") f. show (5) We want to use this table to generate arrays with the job titles of the members of each Organization Group. Question 1. Set job_titles to a table with two columns. The first column should be called Organization Group and have the name of every "Organization Group" once, and the second column should be called Jobs with each row in that second column containing an array of the names of all the job titles within that "Organization Group". Don't worry if there are multiple of the same job titles. (9 Points) Hint 1: Think about how 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. Hint 2: You might need to rename one of the columns. 43]: \# Pick one of the two functions defined below in your call to group. def first_item(array): '"'Returns the first item'" return array.item( () def full_array (array): "'Returns the array that is passed through'"' return array \# Make a call to group using one of the functions above when you define job_titles job_titles = sf.select('Organization Group' , 'Job').group('Organization Group') job_titles 427: 42]: grader.check("q2_1") 42]: q2_1results:q2_1-1result: Test case passed! q2_1-2result: Test case passed! q2_1-3result: Test case passed! q2_1 - 4 result: Trying: np.asarray(job_titles.labels).item(1) == "Jobs" Expecting: True Line 2, in q2_13 Failed example: np.asarray(job_titles.labels).item(1) == "Jobs" Expected: True Got: False

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions