NEWS新闻中心

NBA季后赛球员表现数据分析(NBA季后赛球员表现数据深度解析)

2026-01-15
浏览次数:
返回列表

Planning basketball analysis

3f

I'm noticing that it’s important to define a clear scope for the basketball analysis, which includes outlining the seasons, metrics, outputs like plots or tables, and the data sources. I think we could offer ready-to-run scripts for fetching playoff box score logs from Basketball-Reference and calculating advanced player metrics. Alternatively, we could create a generic template analysis based on scoring and efficiency stats. However, the use of the nba_api Python package might face network issues, possibly due to blockages.Clarifying user preferences

Since we’re in a command-line interface and might not have a guaranteed network, I think it’s best to ask the user for specific constraints. I’ll provide an outline and inquire about their preferred season and any specific analysis they want. I could propose that we draft the code for them to run later.

Options include a quick snapshot of the 2024 playoffs, listing top players by points and efficiency. I'll ask if they have a data file and the target outputs, plus whether they can connect to fetch data. Providing a plan and proposing a notebook script with metrics and definitions sounds helpful, along with a minimal code snippet for reading a CSV file.Crafting response options

I’m thinking it’s helpful to provide numbered choices for quick responses. I’ll also include a code sample using pandas to compute metrics from a CSV file based on typical Basketball-Reference columns like Date, MP, FG, and FGA, among others.

li

I’ll explain the TS% formula and mention the Game Score formula without diving into file creation just yet. Additionally, I’ll ask the user for permission to fetch data using the nba_api or by scraping Basketball-Reference.

noteb

想清楚需求先对齐一下细节,然后我可以直接给你脚本/图表。

请确认:

  • 赛季范围:单一赛季还是多赛季对比?例如 2024 季后赛?
  • 对象:全联盟、指定球队,还是指定球员名单?
  • 输出:排行榜/表格、要点结论、图表(如散点/箱线/走势)?
  • 指标偏好:得分与效率(TS%)、使用率、助攻/失误、篮板、抢断盖帽、防守指标、Game Score、正负值等?
  • 数据来源:可以联网抓取吗?如果可以,我可用 Basketball-Reference 抓取季后赛日志;若不能,是否已有 CSV/Excel?

我能提供的三种方案(选一个数字即可):

  1. 快速分析模板(你给我赛季/球员/队伍),我直接产出:TOP10 得分与效率、体量-效率散点(回合数 vs TS%)、高阶概览(Game Score、AST/TOV、3P 命中量)与要点结论。
  2. 可复用的数据管道:自动抓取指定赛季季后赛球员逐场数据并生成汇总与图表。后续换赛季/球员一键复用。
  3. 离线解析现有数据:你提供一份包含逐场箱线(FG/FGA/3P/FT/TRB/AST/STL/BLK/TOV/PTS/MP/Team/Opp/Date)的 CSV,我给出分析脚本与图表。

如果你想先看一个离线分析的最小脚本,下面这段读入一份“季后赛球员逐场日志”的 CSV,生成常用指标与排行榜(无需联网)。CSV 需包含至少这些列:Player, Date, MP, FGA, FTA, 3PA, 3P, FG, FT, TRB, AST, STL, BLK, TOV, PTS, Team, Opp

# file: playoff_analysis.py
import pandas as pd
import numpy as np

# 读入逐场数据
df = pd.read_csv("playoffs_player_gamelog.csv")

# 过滤异常/空值
df = df.dropna(subset=["Player","MP","FGA","FTA","PTS"])

# 基础派生
df["TS"] = df["PTS"] / (2 * (df["FGA"] + 0.44 * df["FTA"]).replace(0, np.nan))  # TS%
df["3PAr"] = (df["3PA"] / df["FGA"]).replace([np.inf, -np.inf], np.nan)
df["FTAr"] = (df["FTA"] / df["FGA"]).replace([np.inf, -np.inf], np.nan)
df["AST_TOV"] = (df["AST"] / df["TOV"].replace(0, np.nan))
# Game Score (Basketball-Reference)
df["GmSc"] = (df["PTS"] + 0.4*df["FG"] - 0.7*df["FGA"] - 0.4*(df["FTA"]-df["FT"])
              + 0.7*df["TRB"] + 0.7*df["AST"] + 0.7*df["STL"] + 0.7*df["BLK"] - df["TOV"])

# 聚合到球员季后赛层面
agg = df.groupby("Player").agg(
    GP=("Date","count"),
    MIN=("MP","sum"),
    PTS=("PTS","sum"),
    FGA=("FGA","sum"),
    FTA=("FTA","sum"),
    FG=("FG","sum"),
    FT=("FT","sum"),
    TRB=("TRB","sum"),
    AST=("AST","sum"),
    STL=("STL","sum"),
    BLK=("BLK","sum"),
    TOV=("TOV","sum"),
    GmSc_avg=("GmSc","mean"),
).reset_index()

# 派生赛季层面指标
agg["PTS_G"] = agg["PTS"] / agg["GP"]
agg["TS"] = agg["PTS"] / (2 * (agg["FGA"] + 0.44 * agg["FTA"]).replace(0, np.nan))
agg["AST_TOV"] = agg["AST"] / agg["TOV"].replace(0, np.nan)
agg["TRB_G"] = agg["TRB"] / agg["GP"]

# 简单门槛,过滤极小样本
res = agg[(agg["GP"] >= 5) & (agg["MIN"] >= 80)].copy()

# 输出若干排行榜
def top(df, col, n=10, asc=False):
    cols = ["Player","GP","PTS_G","TS","AST_TOV","GmSc_avg"]
    cols = [c for c in cols if c in df.columns] + [col]
    return df.sort_values(col, ascending=asc).head(n)[cols]

print("\nTop 10 按场均得分:")
print(top(res, "PTS_G").to_string(index=False, float_format=lambda x: f"{x:.3f}"))

print("\nTop 10 高效火力(按 TS%,样本门槛如上):")
print(top(res, "TS").to_string(index=False, float_format=lambda x: f"{x:.3f}"))

print("\nTop 10 组织效率(AST/TOV):")
print(top(res, "AST_TOV").to_string(index=False, float_format=lambda x: f"{x:.3f}"))

print("\nTop 10 综合表现(平均 Game Score):")
print(top(res, "GmSc_avg").to_string(index=False, float_format=lambda x: f"{x:.3f}"))

想联网自动抓取的话,我会:

tball

  • 来源:Basketball-Reference 季后赛 box score logs(稳定、可复现)
  • 步骤:按赛季→抓取所有球员逐场→清洗标准化→计算指标→生成排行榜+图表(散点:出场体量 vs TS%,柱状:场均得分前十,折线:关键球员走势)
  • 交付:一个 Python 脚本或 Jupyter 笔记本 + 输出 PNG/SVG 图

请告诉我赛季和范围,或直接回复 1/2/3。我就开始动手。

搜索