- 01 How to Install python software Telugu-vlr train...
- 02 Python IDLE Telugu
- 02 Sublime Text to develop python programs Telugu-...
- 02 How to Install Intellij editor for python telug...
- 03 Writing Your First Python Program telugu | Your...
- 03 Tips for writing python programs in IntelliJ ID...
- 04 Python Programming Data Types Telugu | What are...
- 05 Python Variable Declaration Telugu | Declaring ...
- 06 Command to clear Python Interpreter Console on ...
- 07 Comments in Python In Telugu | Python Comments ...
- 08 Python Arithmetic Operators Telugu | Arithmetic...
- 08 Double Division Operator in Python
- 09 Python Bitwise Operators Telugu-vlr training
- 10 string manipulation functions in python Telugu-...
- 11 The string format method in python-vlr training...
- 12 special charcters for strings in Python Telugu-...
- 13 Comparison, Logical operators in python telugu-...
- 14 if and else statement in python Telugu-vlr trai...
- 15 elif statement in python Telugu-vlr training
- 16 ternary operator in python Telugu-vlr training
- 17 for loop in Python Telugu-vlr training
- 18 multiplication table in python using for statem...
- 19 while break and continue Python Telugu-vlr trai...
- 20 how to create functions in python Telugu-vlr tr...
- 20 range function in python-vlr training
- 21 functions with parameters python Telugu-vlr tra...
- 21 sum of n natural numbers using for loop in pyth...
- 22 fibonacci numbers Program in python-vlr trainin...
- 23 Writing user defined functions in Python-vlr tr...
- 23 Python variable scope Telugu-vlr training
- 23 nested functions python Telugu-vlr training
- 24 recursive function in python telugu-vlr trainin...
- 25 nested functions in python Telugu-vlr training
- 26 Recursive function in python Telugu-vlr trainin...
- 26 functions with receive arguments in python telu...
- 27 lambda function In Python Telugu-vlr training
- 28 running python code with sublimerepl input func...
- 29 file functions in python telugu part 01-vlr tra...
- 30 Python tell and seek functions telugu part 02-v...
- 31 reading lines using for loop in file handling P...
- 32 file attributes in python telugu-vlr training
- 33 write data to file Python-vlr training
- 34 exception and erros in python-vlr training
- 35 value error and type error in python telugu-vlr...
- 36 try and except Exception as in python-vlr train...
- 37 finally block in python-vlr training
- 38 assert and raise in exception handling-vlr trai...
- 39 tuples in python-vlr training
- 40 list in python-vlr training
- 41 list in python part 2-vlr training
- 41 list in python part 3-vlr training
- 42 dictionary In python-vlr training
- 43 sets in python-vlr training
- 44 Modules In Python-vlr training
- 45 packages in Python-vlr training
- 46 Shallow and Deep Copy In Python-vlr training
- 47 copy module in python telugu-vlr training
- 48 Math Module in Python-vlr training
- 49 CMath Module in Python-vlr training
- 50 random module in python-vlr training
- 51 sys module in python-vlr training
Saturday, 10 February 2018
General Python Videos For Beginners
63 csv file read home work 04
https://vlrtraining.com/courses/python-data-science-beginner-tutorial
63 csv file read home work 04
In [6]:
import pandas as pd
sal = pd.read_csv('Salaries.csv')
What was the average (mean) BasePay of all employees per year? (2011-2014) ?
sal.groupby('Year').mean()['BasePay']¶
sal['BasePay']
In [12]:
sal.groupby('Year').mean()['BasePay']
Out[12]:
Year 2011 63595.956517 2012 65436.406857 2013 69630.030216 2014 66564.421924 Name: BasePay, dtype: float64
In [16]:
len(sal['JobTitle'].unique())
Out[16]:
2159
In [17]:
sal['JobTitle'].nunique()
Out[17]:
2159
In [19]:
sal[ sal['year']== 2013][JobTitle'].value_counts().head(5)
Out[19]:
Transit Operator 7036 Special Nurse 4389 Registered Nurse 3736 Public Svc Aide-Public Works 2518 Police Officer 3 2421 Name: JobTitle, dtype: int64
How many Job Titles were represented by only one person in 2013? (e.g. Job Titles with only one occurence in 2013?)
##### sum(sal[sal['Year']==2013]['JobTitle'].value_counts() == 1)¶
In [22]:
sum(sal[sal['Year']==2013]['JobTitle'].value_counts()==1)
Out[22]:
202
How many people have the word Chief in their job title? (This is pretty tricky)
In [26]:
def chie(title):
if 'chief' in title.lower():
return True
else:
return False
sum(sal['JobTitle'].apply(lambda x: chie(x)))
Out[26]:
627
In [27]:
Out[27]:
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.00 | 400184.25 | NaN | 567595.43 | 567595.43 | 2011 | NaN | San Francisco | NaN |
1 | 2 | GARY JIMENEZ | CAPTAIN III (POLICE DEPARTMENT) | 155966.02 | 245131.88 | 137811.38 | NaN | 538909.28 | 538909.28 | 2011 | NaN | San Francisco | NaN |
In [28]:
def chie(title):
if 'chief' in title.lower():
return True
else:
return False
def ram(x):
if 'chief' in x.lower():
return True
else:
return False
In [33]:
ram("kumar ChIef ramesh")
Out[33]:
True
In [35]:
sum(sal['JobTitle'].apply(lambda x: ram(x)))
Out[35]:
627
In [37]:
sal['title_len'] = sal['JobTitle'].apply(len)
In [76]:
#sal[["TotalPayBenefits",'title_len']]
sal[['title_len','TotalPayBenefits']].corr() # No correlation.
Out[76]:
title_len | TotalPayBenefits | |
---|---|---|
title_len | 1.000000 | -0.036878 |
TotalPayBenefits | -0.036878 | 1.000000 |
Subscribe to:
Posts (Atom)