Settle a debate with .apply()
Word has gotten to the Arizona Diamondbacks about your awesome analytics skills. They'd like for you to help settle a debate amongst the managers. One manager claims that the team has made the playoffs every year they have had a win percentage of 0.50 or greater. Another manager says this is not true.
Let's use the below function and the .apply() method to see which manager is correct.
def calc_win_perc(wins, games_played):
win_perc = wins / games_played
return np.round(win_perc,2)
A DataFrame named dbacks_df has been loaded into your session.
Deze oefening maakt deel uit van de cursus
Writing Efficient Python Code
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Display the first five rows of the DataFrame
print(dbacks_df.____())