Skip to content
11 changes: 11 additions & 0 deletions Exercise5b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pandas
wages=pandas.read_csv("wages.csv")
wages.drop([col for col in wages.columns if 'yearsSchool' in col],axis=1,inplace=True)
cc=(wages.sort_values(by='wage'))
print ("Lowest Earner")
print (cc.head(n=1))
print ("Highest Earner")
print (cc.tail(n=1))
print ("Top 10 Female Earners")
numoffemales=wages[wages['wage']>=wages['wage'].nlargest(10).iloc[-1]]['gender'].eq('female').sum()
print (numoffemales)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

8 changes: 8 additions & 0 deletions Exercise5c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pandas
wages=pandas.read_csv("wages.csv")
ed12=wages[wages.yearsSchool==12] #12 years of education
minimum12=min(ed12.wage) #minimum wage of 12
ed16=wages[wages.yearsSchool==16] #16 years of education
minimum16=min(ed16.wage) #minimum wage of 16
print (minimum16-minimum12)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

16 changes: 16 additions & 0 deletions part1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

with open('wages.csv','r') as f:
file = f.readlines()




for line in file:
line = line.split(',')
gender = line[0]
exp = line[1]
str = gender + ' ' + exp + '\n'
with open('new.txt', 'a') as n:
n.write(str)

@lyy005 lyy005 Oct 5, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the unique and sorting part of the question.

data=pandas.read_csv("wages.csv")
genderYears=data.iloc[:,0:2]
unique_genderYears=genderYears.drop_duplicates()
sorted=unique_genderYears.sort_values(by=['gender', 'yearsExperience'])
sorted.to_csv('sortedUniqueWagesPython.txt',header=False,index=False,sep=' ')

-0.5