I'm trying to get the ID from another csv file

Viewed 45

The csv files I read in

games = pd.read_csv("games.csv")
games_details = pd.read_csv("games_details.csv")
players = pd.read_csv("players.csv")
ranking = pd.read_csv("ranking.csv")
teams = pd.read_csv("teams.csv")

Here I got the games season that where greater than 2015 then I got the season gameId only

season = games[games.SEASON > 2015]
gameID = season.GAME_ID

Here I'm trying to get the game ID from games_details but i only want the id's that was stored in gameID but it's not returning anything

for i in gameID:
        detail = games_details[games_details.GAME_ID == i ]
    
    id = detail.GAME_ID
   
    print(id, "\t " ,gameid)
1 Answers

Use isin function:

print(games_details[games_details['GAME_ID'].isin(gameID)].GAME_ID)
Related