31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from nba_api.stats.endpoints import playercareerstats
|
|
# import /nba_api/stats/static/players.py
|
|
from nba_api.stats.static import players
|
|
import json
|
|
|
|
playerID = "1627734"
|
|
career = playercareerstats.PlayerCareerStats(player_id=playerID)
|
|
player = players.find_players_by_last_name("Sabonis")
|
|
print(player)
|
|
|
|
# career.get_data_frames()[0]
|
|
|
|
career.get_json()
|
|
y = json.loads(career.get_json())
|
|
career_totals_all_star_season = None
|
|
for result_set in y['resultSets']:
|
|
if result_set['name'] == 'CareerTotalsRegularSeason':
|
|
career_totals_all_star_season = result_set
|
|
break
|
|
|
|
# Extract PLAYER_ID from CareerTotalsAllStarSeason
|
|
player_id = None
|
|
if career_totals_all_star_season:
|
|
player_id = career_totals_all_star_season['rowSet'][0][19]
|
|
row = career_totals_all_star_season['rowSet'][0]
|
|
total_assists = row[19] # Assuming assists is at index 19
|
|
all_star_season_year = row[1] # Assuming season year is at index 1
|
|
|
|
|
|
print("PLAYER_ID from CareerTotalsAllStarSeason:", player_id)
|
|
print("Year of the all-star season:", all_star_season_year) |