In [1]:
#import everything we need 

from nba_api.stats.static import players
from nba_api.stats.endpoints import playergamelog
from nba_api.stats.library.parameters import SeasonAll
from nba_api.stats import endpoints
import pandas as pd 
In [2]:
#Update player we want to pull gamelogs for, along with the season 
playerNametoGrab = 'Jamal Murray'
seasonToGrab = '2019'
filename = './'
In [3]:
filename = filename + playerNametoGrab + seasonToGrab + '.csv'
In [4]:
#Grabbing the ID for the playerNametoGrab 
player_dict = players.get_players()

player = [player for player in player_dict if player['full_name'] == playerNametoGrab][0]
player_id = player['id']
In [5]:
#Grabbing the player game log data based on playerNametoGrab and seasonToGrab
gamelog_player = playergamelog.PlayerGameLog(player_id=player_id, season = seasonToGrab)
In [6]:
df_player_games = gamelog_player.get_data_frames()[0]
In [7]:
#Display the data within notebook 
df_player_games
Out[7]:
SEASON_ID Player_ID Game_ID GAME_DATE MATCHUP WL MIN FGM FGA FG_PCT ... DREB REB AST STL BLK TOV PF PTS PLUS_MINUS VIDEO_AVAILABLE
0 22019 1627750 0021901318 AUG 14, 2020 DEN @ TOR L 10 4 5 0.800 ... 0 0 1 1 0 0 2 11 -6 1
1 22019 1627750 0021901307 AUG 12, 2020 DEN vs. LAC L 25 3 8 0.375 ... 3 3 6 0 0 0 2 10 1 1
2 22019 1627750 0021901296 AUG 10, 2020 DEN @ LAL L 25 6 10 0.600 ... 3 4 3 2 0 1 0 14 -7 1
3 22019 1627750 0021901281 AUG 08, 2020 DEN vs. UTA W 39 10 25 0.400 ... 10 12 8 0 1 2 1 23 7 1
4 22019 1627750 0021900973 MAR 11, 2020 DEN @ DAL L 38 10 22 0.455 ... 6 6 5 1 0 4 2 25 5 1
5 22019 1627750 0021900958 MAR 09, 2020 DEN vs. MIL W 39 9 17 0.529 ... 4 5 6 1 1 4 3 21 15 1
6 22019 1627750 0021900942 MAR 07, 2020 DEN @ CLE L 31 7 14 0.500 ... 1 5 7 0 0 2 2 17 1 1
7 22019 1627750 0021900926 MAR 05, 2020 DEN @ CHA W 35 6 14 0.429 ... 2 3 6 1 0 1 1 18 -8 1
8 22019 1627750 0021900913 MAR 03, 2020 DEN vs. GSW L 38 3 14 0.214 ... 5 6 3 1 0 1 2 14 -9 1
9 22019 1627750 0021900898 MAR 01, 2020 DEN vs. TOR W 37 8 15 0.533 ... 1 1 5 0 0 2 3 22 15 1
10 22019 1627750 0021900886 FEB 28, 2020 DEN @ LAC L 26 5 12 0.417 ... 2 2 2 1 0 2 1 11 -16 1
11 22019 1627750 0021900860 FEB 25, 2020 DEN vs. DET W 33 5 12 0.417 ... 5 5 8 1 1 1 2 16 25 1
12 22019 1627750 0021900844 FEB 23, 2020 DEN vs. MIN W 35 8 14 0.571 ... 1 1 6 1 0 3 1 19 21 1
13 22019 1627750 0021900831 FEB 21, 2020 DEN @ OKC L 38 8 16 0.500 ... 5 6 4 1 1 5 0 21 -2 1
14 22019 1627750 0021900817 FEB 12, 2020 DEN vs. LAL L 44 13 25 0.520 ... 3 3 10 0 0 2 2 32 -4 1
15 22019 1627750 0021900799 FEB 10, 2020 DEN vs. SAS W 34 11 21 0.524 ... 2 2 6 1 0 2 4 26 -4 1
16 22019 1627750 0021900784 FEB 08, 2020 DEN @ PHX W 35 14 17 0.824 ... 5 5 5 1 1 5 4 36 5 1
17 22019 1627750 0021900762 FEB 05, 2020 DEN @ UTA W 43 12 26 0.462 ... 1 2 4 0 1 3 2 31 5 1
18 22019 1627750 0021900753 FEB 04, 2020 DEN vs. POR W 20 6 9 0.667 ... 2 2 6 0 0 2 0 20 15 1
19 22019 1627750 0021900610 JAN 15, 2020 DEN vs. CHA W 15 2 7 0.286 ... 1 1 1 2 0 3 0 5 4 1
20 22019 1627750 0021900589 JAN 12, 2020 DEN vs. LAC W 38 4 12 0.333 ... 3 4 2 0 0 2 0 19 5 1
21 22019 1627750 0021900582 JAN 11, 2020 DEN vs. CLE L 35 10 22 0.455 ... 3 5 3 3 0 1 1 24 -4 1
22 22019 1627750 0021900559 JAN 08, 2020 DEN @ DAL W 31 7 18 0.389 ... 3 3 5 0 0 1 3 14 -1 1
23 22019 1627750 0021900543 JAN 06, 2020 DEN @ ATL W 34 6 13 0.462 ... 5 5 8 1 1 1 2 16 9 1
24 22019 1627750 0021900528 JAN 04, 2020 DEN @ WAS L 35 13 19 0.684 ... 1 1 4 2 1 2 2 39 1 1
25 22019 1627750 0021900509 JAN 02, 2020 DEN @ IND W 38 8 18 0.444 ... 5 5 7 1 0 0 1 22 11 1
26 22019 1627750 0021900501 DEC 31, 2019 DEN @ HOU L 30 5 14 0.357 ... 0 0 6 1 0 2 3 12 -9 1
27 22019 1627750 0021900489 DEC 29, 2019 DEN vs. SAC W 33 3 10 0.300 ... 4 4 7 2 1 3 3 13 7 1
28 22019 1627750 0021900472 DEC 28, 2019 DEN vs. MEM W 36 5 14 0.357 ... 4 5 5 0 0 1 1 15 -2 1
29 22019 1627750 0021900459 DEC 25, 2019 DEN vs. NOP L 28 2 10 0.200 ... 2 4 3 1 0 2 4 8 -4 1
30 22019 1627750 0021900451 DEC 23, 2019 DEN @ PHX W 35 12 19 0.632 ... 2 3 7 2 0 4 2 28 6 1
31 22019 1627750 0021900443 DEC 22, 2019 DEN @ LAL W 32 3 11 0.273 ... 2 3 5 1 0 2 0 6 16 1
32 22019 1627750 0021900427 DEC 20, 2019 DEN vs. MIN W 37 9 19 0.474 ... 2 6 5 3 0 3 1 28 15 1
33 22019 1627750 0021900414 DEC 18, 2019 DEN vs. ORL W 36 11 19 0.579 ... 4 5 1 1 0 4 2 33 12 1
34 22019 1627750 0021900392 DEC 15, 2019 DEN vs. NYK W 33 5 14 0.357 ... 3 6 4 0 0 1 2 14 2 1
35 22019 1627750 0021900387 DEC 14, 2019 DEN vs. OKC W 33 6 15 0.400 ... 5 5 7 1 0 2 2 14 19 1
36 22019 1627750 0021900370 DEC 12, 2019 DEN vs. POR W 28 4 11 0.364 ... 6 6 3 1 0 3 1 12 -1 1
37 22019 1627750 0021900353 DEC 10, 2019 DEN @ PHI L 5 0 1 0.000 ... 1 1 0 0 0 0 0 0 3 1
38 22019 1627750 0021900335 DEC 08, 2019 DEN @ BKN L 33 7 17 0.412 ... 2 3 5 0 0 2 3 21 -14 1
39 22019 1627750 0021900323 DEC 06, 2019 DEN @ BOS L 34 5 14 0.357 ... 2 3 3 2 1 1 1 10 -10 1
40 22019 1627750 0021900317 DEC 05, 2019 DEN @ NYK W 22 5 9 0.556 ... 1 3 4 0 0 1 0 14 10 1
41 22019 1627750 0021900304 DEC 03, 2019 DEN vs. LAL L 36 8 17 0.471 ... 5 5 5 2 1 1 0 22 -7 1
42 22019 1627750 0021900280 NOV 30, 2019 DEN @ SAC L 37 6 16 0.375 ... 4 4 6 2 0 2 2 15 -5 1
43 22019 1627750 0021900252 NOV 26, 2019 DEN vs. WAS W 25 7 12 0.583 ... 2 2 2 3 1 5 1 16 12 1
44 22019 1627750 0021900238 NOV 24, 2019 DEN vs. PHX W 34 9 21 0.429 ... 6 7 3 1 0 0 1 22 11 1
45 22019 1627750 0021900222 NOV 22, 2019 DEN vs. BOS W 38 9 18 0.500 ... 5 6 5 2 0 3 1 22 8 1
46 22019 1627750 0021900211 NOV 20, 2019 DEN vs. HOU W 33 4 16 0.250 ... 1 1 9 6 0 5 5 10 12 1
47 22019 1627750 0021900186 NOV 17, 2019 DEN @ MEM W 31 14 24 0.583 ... 4 4 8 3 1 0 1 39 23 1
48 22019 1627750 0021900166 NOV 14, 2019 DEN vs. BKN W 29 1 11 0.091 ... 3 5 4 1 0 2 0 4 2 1
49 22019 1627750 0021900150 NOV 12, 2019 DEN vs. ATL L 33 7 16 0.438 ... 1 3 8 1 1 0 2 18 10 1
50 22019 1627750 0021900132 NOV 10, 2019 DEN @ MIN W 35 6 19 0.316 ... 5 5 2 1 0 7 4 15 -3 1
51 22019 1627750 0021900123 NOV 08, 2019 DEN vs. PHI W 37 10 18 0.556 ... 5 6 11 1 2 2 2 22 16 1
52 22019 1627750 0021900102 NOV 05, 2019 DEN vs. MIA W 33 9 15 0.600 ... 3 5 4 2 0 5 0 21 17 1
53 22019 1627750 0021900079 NOV 02, 2019 DEN @ ORL W 32 7 15 0.467 ... 3 4 2 1 0 2 2 22 10 1
54 22019 1627750 0021900067 OCT 31, 2019 DEN @ NOP L 26 6 14 0.429 ... 3 3 6 1 0 3 2 14 -11 1
55 22019 1627750 0021900053 OCT 29, 2019 DEN vs. DAL L 34 7 13 0.538 ... 6 6 1 0 0 0 3 16 11 1
56 22019 1627750 0021900050 OCT 28, 2019 DEN @ SAC W 31 6 14 0.429 ... 3 4 3 1 0 2 3 18 7 1
57 22019 1627750 0021900023 OCT 25, 2019 DEN vs. PHX W 41 8 19 0.421 ... 6 7 3 1 1 3 4 27 3 1
58 22019 1627750 0021900013 OCT 23, 2019 DEN @ POR W 34 4 14 0.286 ... 4 5 6 1 0 2 1 14 9 1

59 rows × 27 columns

In [8]:
#Save the data to the same folder that contains the notebook, example will be named 'Jamal Murray2019.csv'
df_player_games.to_csv(filename)