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
22 changes: 22 additions & 0 deletions Exercise_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Challenge 1
import pandas as pd
data=pd.read_csv("/Users/chenyingying/Documents/Intro_Biocom_ND_319_Tutorial5/wages.csv")
data1=data.iloc[:,0:2]
stdout=data1.drop_duplicates().sort_values(['gender','yearsExperience'])
stdout=pd.DataFrame(stdout)
stdout.to_csv('stdout.csv',sep=',',index=False)

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

# Challenge 2
#The gender, yearsExperience, wage for the lowest earners
data.sort_values('wage').head(n=1).loc[:,['gender','yearsExperience','wage']]
#The gender, yearsExperience, wage for the highest earners
data.sort_values('wage').tail(n=1).loc[:,['gender','yearsExperience','wage']]
#females in the top ten earners
sum(data.sort_values('wage').tail(n=10).iloc[:,0]=='female')

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

# Challenge 3
import matplotlib.pyplot as plt
y=[data.loc[data.iloc[:,2].values==12,'wage'].min(),data.loc[data.iloc[:,2].values==16,'wage'].min()]
x=[12,16]
plt.scatter(x,y)
plt.title('Effect of graduating college on the min wage')
plt.xlabel('yearsSchool')
plt.ylabel('Minimum wage')

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

Binary file added Figure_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions stdout.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
gender,yearsExperience
female,1
female,2
female,3
female,4
female,5
female,6
female,7
female,8
female,9
female,10
female,11
female,12
female,13
female,14
female,15
female,16
male,2
male,3
male,4
male,5
male,6
male,7
male,8
male,9
male,10
male,11
male,12
male,13
male,14
male,15
male,16
male,17
male,18