Luka Doncic’s Personal Foul History using NBA Data

Ben Ballard
3 min readDec 7, 2023
NBA Player gets Technical Foul

I noticed in a previous post where I looked into NBA Teams statistical ranking improvement and worsening that the Dallas Mavericks had significant improvement in Personal Fouls this season. Now obviously that’s a Team Ranking, but my mind went to Luka, who over the course of his career is often mentioned for his troubles.

Luka Doncic Personal Fouls Per Year
Luka Doncic Fouls per Year

There is a different in Technical Fouls and Personal Fouls, but with the NBA API, I could only find access to personal fouls. The following is the code I ran to access the Personal Foul data for Luka.

import matplotlib.pyplot as plt
import pandas as pd
from nba_api.stats.endpoints import playergamelog

# Initialize an empty DataFrame to store all game logs
all_seasons_logs_df = pd.DataFrame()

# List of seasons to loop through (update this list as needed)
seasons = ['2018-19', '2019-20', '2020-21', '2021-22', '2022-23']

# Fetch game logs for Luka Doncic for each season
for season in seasons:
player_logs = playergamelog.PlayerGameLog(player_id='1629029', season=season)
season_logs_df = player_logs.get_data_frames()[0]
all_seasons_logs_df = pd.concat([all_seasons_logs_df, season_logs_df], ignore_index=True)

# Convert game dates to…

--

--

Ben Ballard

Here for Data Science and Machine Learning. MS Data Science @UVA | Boomer | Mavs | Working on NBAanalytics.com.