can you explain this code , which is written to perform the tasks in the attached image import pandas as pd import numpy as np URL = "https://bit.ly/38zhU5T" df=pd.read_csv(URL) arr=df.to_numpy() employee_notworked=[0,0,0,0] #Array to store the number of projects each employee did not work employee=[[]]*4 #list of projects worked by employees. min_award=[0,0,0,0] #Array to store minimum award received by employees. max_award=[0]*4 #Array to store maximum award received by employees. avg_awards=[0]*4 #Array to store the average award received by employees. maxaward_employee=0 project_id=[None]*4 #Array to store project_id in which each employee received the maximum award for working on that project
can you explain this code , which is written to perform the tasks in the attached image import pandas as pd import numpy as np URL = "https://bit.ly/38zhU5T" df=pd.read_csv(URL) arr=df.to_numpy() employee_notworked=[0,0,0,0] #Array to store the number of projects each employee did not work employee=[[]]*4 #list of projects worked by employees. min_award=[0,0,0,0] #Array to store minimum award received by employees. max_award=[0]*4 #Array to store maximum award received by employees. avg_awards=[0]*4 #Array to store the average award received by employees. maxaward_employee=0 project_id=[None]*4 #Array to store project_id in which each employee received the maximum award for working on that project
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
can you explain this code , which is written to perform the tasks in the attached image
import pandas as pd
import numpy as np
URL = "https://bit.ly/38zhU5T"
df=pd.read_csv(URL)
arr=df.to_numpy()
employee_notworked=[0,0,0,0] #Array to store the number of projects each employee did not work
employee=[[]]*4 #list of projects worked by employees.
min_award=[0,0,0,0] #Array to store minimum award received by employees.
max_award=[0]*4 #Array to store maximum award received by employees.
avg_awards=[0]*4 #Array to store the average award received by employees.
maxaward_employee=0
project_id=[None]*4 #Array to store project_id in which each employee received the maximum award for working on that project
project_lang=[None]*4 #Array to store project_lang in which each employee received the maximum award for working on that project
count=[0]*4 #A variable to store num of projects worked by the employees.
index=0
for i in range(len(arr)):
if(arr[i][2] == 1 or arr[i][2] == 2):
employee[0].append(arr[i][0])
if(min_award[0] > arr[i][6] or min_award[0] == 0):
min_award[0] = arr[i][6]
if(max_award[0] < arr[i][6] ):
project_id[0]=arr[i][0]
project_lang[0]=arr[i][1]
max_award[0] = arr[i][6]
avg_awards[0] += arr[i][6]
count[0] +=1
else:
employee_notworked[0]+=1
if( arr[i][3] == 1 or arr[i][3] == 2):
employee[1].append(arr[i][0])
if(min_award[1] > arr[i][6] or min_award[1] == 0):
min_award[1] = arr[i][6]
if(max_award[1] < arr[i][6] ):
project_id[1]=arr[i][0]
project_lang[1]=arr[i][1]
max_award[1] = arr[i][6]
avg_awards[1] += arr[i][6]
count[1] +=1
else:
employee_notworked[1]+=1
if( arr[i][4] == 1 or arr[i][4] == 2):
employee[2].append(arr[i][0])
if(min_award[2] > arr[i][6] or min_award[2] == 0):
min_award[2] = arr[i][6]
if(max_award[2] < arr[i][6] ):
project_id[2]=arr[i][0]
project_lang[2]=arr[i][1]
max_award[2] = arr[i][6]
avg_awards[2] += arr[i][6]
count[2] +=1
else:
employee_notworked[2]+=1
if( arr[i][5] == 1 or arr[i][5] == 2):
employee[3].append(arr[i][0])
if(min_award[3] > arr[i][6] or min_award[3] == 0):
min_award[3] = arr[i][6]
if(max_award[3] < arr[i][6] ):
project_id[3]=arr[i][0]
project_lang[3]=arr[i][1]
max_award[3] = arr[i][6]
avg_awards[3] += arr[i][6]
count[3] +=1
else:
employee_notworked[3]+=1
for i in range(len(avg_awards)):
avg_awards[i]/=count[i]
print("\n")
for i in range(4):
print("List of projects worked by Employee - :",i+1)
print(employee[i])
print("Average Award of employee - ", i+1," : ",avg_awards[i])
print("Min Award of employee - ", i+1," : ",min_award[i])
print("Max Award of employee - ", i+1," : ",max_award[i])
print("Project id employee - ",i+1," got max award : ",project_id[i])
print("Project Languuage employee - ",i+1," got max award : ",project_lang[i])
print("Not worked projects of employee - ",i+1," : ",employee_notworked[i])
print("\n")
if(max_award[i]>maxaward_employee):
maxaward_employee =max_award[i]
index=1
print(" Employee that got max awards: ")
if(index ==1):
print("Employee-1")
elif(index ==2):
print("Employee-2")
elif(index ==3):
print("Employee-3")
else:
print("Employee-4")
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education