mynnnnnnew 3

pdf

School

University of California, Berkeley *

*We aren’t endorsed by this school

Course

61A

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

2

Uploaded by PresidentBeaver2359

Report
(a) Write pandas code to returns the 10 most common middle names among gold medal winners as pandas Series. The column Name contains the first name, the middle name, and the last name of each athlete that are separated by space. You may assume that all athletes in the table have a middle name. (b) Which of the following lines of Pandas code will output the the most number of medals won by a single athlete? □ A. ath[’ID’].groupby(’ID’).count().iloc[0] □ B. ath[[’ID’]].groupby(’ID’).count().iloc[0] □ C. ath[[’Name’, ’Medal’]].groupby(’Name’).count().sort values(’Medal’, ascending = False).iloc[0] □ D. ath[[’ID’, ’Medal’]].groupby(’ID’).size().iloc[0] □ E. ath[[’Name’, ’Medal’]].groupby(’Name’).sum().iloc[0] □ F. ath[[’Name’, ’Medal’]].groupby(’Name’).count().iloc[0].sort values( ’Medal’, ascending = False) Exam Prep Section #1 4 (c) What are the oldest athletes to participate in each sport along with the correspond- ing year in which they participated? (d) Fill in the blanks below to return the names of all the athletes who won a medal after a gap of 10 years or more of not winning any Olympics medals. You may assume that each individual’s name is unique to them. def filter_func(subframe): return ath.sort_values( ) \ [ ] \ .groupby( ) \ .filter(filter_func)[’Name’] \ .unique() 2. We will work with an Olympics dataset containing the names of all athletes who par-
ticipated in the Olympic Games, including all the Games from Athens 1896 to Tokyo 2020. We refer to this dataframe as ath. The first 5 lines of the table are shown below. You may assume that the ID column is unique to each athlete and that the only column with null values are height, weight, and medal.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help