May-10-2024, 06:07 PM
(This post was last modified: May-10-2024, 06:07 PM by deanhystad.)
You can simplify the code that makes the dataframe:
# make a list of players players = [] for element in elements: player = {"id", element["id"]} # Makes a dictionary for the player player.update{element.stats} # Adds all stats to the player. players.append(player) # Make dataframe containing all players and stats. dataset = pd.DataFrame(players) # Can make dataframe that has particular stats offense = dataset[["id", "goals_scored", "assists"]