Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pandas

wages = pandas.read_csv("wages.csv")

genderYears = pandas.DataFrame(wages,columns=['gender','yearsExperience'])
genderYears.drop_duplicates(['gender','yearsExperience'], keep='first', inplace=True)
genderYears.sort_values(['gender','yearsExperience'], ascending=[True, True], inplace=True)
genderYears.to_csv('uniqueGenderYears.txt', sep=' ')

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

print("Highest earner:")
print(wages.loc[wages['wage'].argmax(), ['gender', 'yearsExperience', 'wage']])

print("Lowest earner:")
print(wages.loc[wages['wage'].argmin(), ['gender', 'yearsExperience', 'wage']])

@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.

Can't find the answer to the number of females in the top ten earners

-0.25

collegeSalery = 0;
highSchoolSalery = 0;
collegeCount = 0;
highSchoolCount = 0;

for index in range(0, 3294 ,1):
if wages.loc[index, 'yearsSchool'] >= 16:
collegeCount += 1
collegeSalery += wages.loc[index, 'wage']
if wages.loc[index, 'yearsSchool'] <= 12:
highSchoolCount += 1
highSchoolSalery += wages.loc[index, 'wage']

collegeSalery = collegeSalery / collegeCount
highSchoolSalery = highSchoolSalery / highSchoolCount
print("Average salery for college graduates:")
print(collegeSalery)
print("Average salery for high school graduates:")
print(highSchoolSalery)

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.

The code looks good. But the question was asking the difference of the minimum wage (not average) between the two groups.

12 changes: 12 additions & 0 deletions solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy
import os
os.listdir(".")
os.chdir('/Users/zoeloh/Desktop/Intro_Biocom_ND_319_Tutorial5')
data = numpy.loadtxt(fname="test.dat",delimiter=" ")
data

data[:,0]==0

data[;,0]>2

data[data[:,0]>2,:]
34 changes: 34 additions & 0 deletions uniqueGenderYears.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
gender yearsExperience
168 female 1
215 female 2
15 female 3
37 female 4
23 female 5
27 female 6
9 female 7
4 female 8
0 female 9
7 female 10
2 female 11
1 female 12
17 female 13
350 female 14
46 female 15
623 female 16
1784 male 2
1658 male 3
1650 male 4
1599 male 5
1594 male 6
1570 male 7
1581 male 8
1579 male 9
1569 male 10
1573 male 11
1571 male 12
1617 male 13
1589 male 14
1605 male 15
1608 male 16
1959 male 17
1942 male 18