![613 613](/uploads/1/2/6/2/126258573/144961336.jpg)
Join GitHub today
Standard Edition Section Inquiry # Question Reply API Standard 618 - Reciprocating Compressors for Petroleum, Chemical, and Gas Industry Services 618 4th Ed. June 1995 2.5.2 According to 2.5.2 of API Standard 618, 'except for the belt driven units, the vendor shall provide a torsional analysis of the complete drive train.
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
wblakecannonCompleted 12-manipulating-dataframes-with-pandas/05-putting-it-all-to…a46499aJan 17, 2018
1 contributor
'' |
Using .nunique() to rank by distinct sports |
You may want to know which countries won medals in the most distinct sports. The .nunique() method is the principal aggregation here. Given a categorical Series S, S.nunique() returns the number of distinct categories. |
INSTRUCTIONS |
100XP |
Group medals by 'NOC'. |
Compute the number of distinct sports in which each country won medals. To do this, select the 'Sport' column from country_grouped and apply .nunique(). |
Sort Nsports in descending order with .sort_values() and ascending=False. |
Print the first 15 rows of Nsports. This has been done for you, so hit 'Submit Answer' to see the result. |
'' |
# Group medals by 'NOC': country_grouped |
country_grouped = medals.groupby('NOC') |
# Compute the number of distinct sports in which each country won medals: Nsports |
Nsports = country_grouped['Sport'].nunique() |
# Sort the values of Nsports in descending order |
Nsports = Nsports.sort_values(ascending=False) |
# Print the top 15 rows of Nsports |
print(Nsports.head(15)) |
![Api 616 Api 616](/uploads/1/2/6/2/126258573/950277420.jpg)
Copy lines Copy permalink