Screenshot 2023-11-09 at 7.13.56 PM

png

School

Georgia State University *

*We aren’t endorsed by this school

Course

3300

Subject

Computer Science

Date

Dec 6, 2023

Type

png

Pages

1

Uploaded by rachelbrown2014

Report
A participant has enabled Closed Captioning Midterm 2: Eall 2023 Note that this is just the head and tail of the full demo result. We have loaded the true result into true_demo_soln_ex3 if you want to do a full comparison. In [28]: ### Exercise 3 solution def who won(event_df: pd.DataFrame) -> pd.DataFrame: # Identify the home and away scores at the end of the game. You can do this either by sorting # based on timeLeft or by finding the maximum score for each team. home_team won = event_df['homeScore'].max() > event_df['awayScore'].max() # Determine which team (home team or away team) had the higher score at the end of the game. # Your solution should return a copy of event df with a new column won # that is set to True where the team on offense won the game and False if the other won the game. df = event_df.copy() # If the home team won then won will have the same values as homeTeamPoss. if home_team won: df['won'] = df['homeTeamPoss"'] # If the away team won then won will have the opposite values of homeTeamPoss. else: df['won'] = ~df['homeTeamPoss"'] return df 1 ### demo function call demo_soln_ex3 = who won(demo_event df ex3) \ display(demo soln_ex3.head()) display(demo soln ex3.tail()) yS h S homeTeamPoss timelLeft won | 0 0 0 True 3600 True 1 0 0 False 3600 False 2 0 0 False 3559 False 3 0 0 False 3523 False 4 0 0 False 3490 False y homeTeamPoss timeleft won 139 6 26 False 149 False |
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help