-
Notifications
You must be signed in to change notification settings - Fork 11
burton-doherty submission #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ###Exercise 5-1### | ||
| import pandas as pd | ||
| wages=pd.read_table("wages.csv",",") | ||
| gen_years=wages.iloc[0:len(wages),0:2] | ||
| gen_years=gen_years.sort_values(by=['gender','yearsExperience'], ascending=[1,1]) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question was asking to print out only the unique combinations. You can use drop_duplicates to only keep the unique combinations: -0.25 |
||
| gen_years.to_csv('ex5_1.txt', header=True, index=False, sep=" ") | ||
|
|
||
| ###Exercise 5-2### | ||
| import pandas as pd | ||
| wages=pd.read_table("wages.csv",",") | ||
| wage_low=wages.iloc[0:len(wages),[0,1,3]] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or you can use: |
||
| wage_low=wage_low.sort_values(by=['wage'], ascending=[1]) | ||
| print ("The lowest wage in both genders is:") | ||
| print (wage_low[:1]) | ||
|
|
||
| wage_high=wages.iloc[0:len(wages),[0,1,3]] | ||
| wage_high=wage_high.sort_values(by=['wage'], ascending=[0]) | ||
| print ("The highest wage in both genders is:") | ||
| print (wage_high[:1]) | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
| wages_10=wage.high.iloc[0:10,0:2] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wage.high should be wage_high |
||
| Ftot=wages_10.gender.eq('female').sum() | ||
| print ("Number of Females in the Top 10 Wages:") | ||
| print (Ftot) | ||
|
|
||
| ###Exercise 5-3### | ||
| import pandas as pd | ||
| wages=pd.read_table("wages.csv",",") | ||
| no_college=min(wages.wage[wages.yearsSchool==12]) | ||
| yes_college=min(wages.wage[wages.yearsSchool==16]) | ||
|
|
||
| print("The minimum wage for non college grads is", no_college) | ||
| print("The minimum wage for college grads is", yes_college) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can just use read_csv:
wages=pandas.read_csv("wages.csv")