Challenge: Team Leaders Table
Coaches often want to quickly identify team leaders in key statistics. Use pandas to automate this process.
Swipe to start coding
Write a function that takes a DataFrame with columns 'athlete', 'goals', and 'assists' and returns a new DataFrame containing only the athletes who have the highest number of goals or assists.
- Find the maximum value in the
'goals'column. - Find the maximum value in the
'assists'column. - Select all rows where the value in
'goals'equals the maximum goals or the value in'assists'equals the maximum assists. - Return a DataFrame with only these rows.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.76
Challenge: Team Leaders Table
Swipe to show menu
Coaches often want to quickly identify team leaders in key statistics. Use pandas to automate this process.
Swipe to start coding
Write a function that takes a DataFrame with columns 'athlete', 'goals', and 'assists' and returns a new DataFrame containing only the athletes who have the highest number of goals or assists.
- Find the maximum value in the
'goals'column. - Find the maximum value in the
'assists'column. - Select all rows where the value in
'goals'equals the maximum goals or the value in'assists'equals the maximum assists. - Return a DataFrame with only these rows.
Solution
Thanks for your feedback!
single