/ Python And R Data science skills: 61 home work 02
Showing posts with label 61 home work 02. Show all posts
Showing posts with label 61 home work 02. Show all posts

Saturday, 10 February 2018

61 csv file read home work 02

https://vlrtraining.com/courses/python-data-science-beginner-tutorial 61 csv file read home work 02
In [1]:
import pandas as pd
sal = pd.read_csv('Salaries.csv')

What is the job title of JOSEPH DRISCOLL ? Note: Use all caps, otherwise you may get an answer that doesn't match up (there is also a lowercase Joseph Driscoll).

sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['JobTitle']

How much does JOSEPH DRISCOLL make (including benefits)?

sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['TotalPayBenefits']

In [3]:
sal.head(1)
Out[3]:
Id EmployeeName JobTitle BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits Year Notes Agency Status
0 1 NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY 167411.18 0.0 400184.25 NaN 567595.43 567595.43 2011 NaN San Francisco NaN
In [7]:
sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['JobTitle']
Out[7]:
24    CAPTAIN, FIRE SUPPRESSION
Name: JobTitle, dtype: object
In [8]:
sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['TotalPayBenefits']
Out[8]:
24    270324.91
Name: TotalPayBenefits, dtype: float64

What is the name of highest paid person (including benefits)?

sal[sal['TotalPayBenefits']== sal['TotalPayBenefits'].max()]

In [9]:
sal['TotalPayBenefits'].max()
Out[9]:
567595.43000000005
In [11]:
sal[sal['TotalPayBenefits']== sal['TotalPayBenefits'].max()]['EmployeeName']
Out[11]:
0    NATHANIEL FORD
Name: EmployeeName, dtype: object
In [12]:
sal.loc[sal['TotalPayBenefits'].idxmax()]
Out[12]:
Id                                                               1
EmployeeName                                        NATHANIEL FORD
JobTitle            GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY
BasePay                                                     167411
OvertimePay                                                      0
OtherPay                                                    400184
Benefits                                                       NaN
TotalPay                                                    567595
TotalPayBenefits                                            567595
Year                                                          2011
Notes                                                          NaN
Agency                                               San Francisco
Status                                                         NaN
Name: 0, dtype: object
In [16]:
sal['TotalPayBenefits'].idxmax()
Out[16]:
0
In [20]:
sal.loc[sal['TotalPayBenefits'].idxmax()]["EmployeeName"]
Out[20]:
'NATHANIEL FORD'
In [18]:
sal.loc[0]["EmployeeName"]
Out[18]:
'NATHANIEL FORD'