#microsoft

Описание к видео #microsoft

Given a list of projects and employees mapped to each project, calculate by the amount of project budget allocated to each employee . The output should include the project title and the project budget rounded to the closest integer. Order your list by projects with the highest budget per employee first.

Steps to Solve this question:
1. Calculate Number of employees associated to each Project.
2. Join the two tables based on common attribute: "Project_id".
3. Make a new column of "budget_emp" that is budget associated to each employee who is doing the particular project.
4. Sort the values according to the "budget_emp" in decreasing order.

Code:
import pandas as pd
df1=ms_emp_projects
df1=df1.groupby('project_id')['emp_id'].count().reset_index()
df=pd.merge(df1,ms_projects,left_on='project_id',right_on='id',how='inner')
df['budget_emp']=round(df['budget']/df['emp_id'])
df[['title','budget_emp']].sort_values(by=['budget_emp'],ascending=False)

#like #share #subscribemychannel

Комментарии

Информация по комментариям в разработке