Finalizing next steps
I'm considering how to run the Python script rank_cba.py with a specific path. However, it seems like we shouldn't actually execute it just yet. Instead, it might be better to focus on proposing the next steps for the user. I want to make sure everything is clear before moving forward and that the user feels supported in whatever they need to do next. Let's go ahead and produce that final answer!

想做哪个赛季、什么口径的“赛季表现排行榜”?我先确认下需求就能给你榜单或脚本。

请确认
可选方案
如果你已有数据文件,下面这个最小脚本可直接把任意赛季的 CSV 生成多项排行榜与一个“综合评分”榜。你只要确保列名包含常见统计:Player, Team, GP, MIN, PTS, REB, AST, STL, BLK, TOV, FGA, FGM, 3PA, 3PM, FTA, FTM。
示例脚本(Python)

# scripts/cba_rank.py
import argparse, pandas as pd, numpy as np
def ts_pct(df):
pts = df["PTS"]; fga = df["FGA"]; fta = df["FTA"]
denom = (2*(fga + 0.44*fta)).replace(0, np.nan)
return (pts/denom).fillna(0.0)
def per36(df, col):
return (df[col] / df["MIN"] * 36).replace([np.inf, -np.inf], 0).fillna(0.0)
def zscore(s):
return (s - s.mean()) / (s.std(ddof=0) if s.std(ddof=0) != 0 else 1)
def build_score(df):
# Simple, interpretable composite; adjust weights as needed.
df = df.copy()
df["PTS36"] = per36(df, "PTS")
df["REB36"] = per36(df, "REB")
df["AST36"] = per36(df, "AST")
df["STK36"] = per36(df, "STL") + per36(df, "BLK")
df["TOV36"] = per36(df, "TOV")
df["TS"] = ts_pct(df)
score = (
0.40*zscore(df["PTS36"]) +
0.18*zscore(df["TS"]) +
0.15*zscore(df["AST36"]) +
0.12*zscore(df["REB36"]) +
0.10*zscore(df["STK36"]) -
0.15*zscore(df["TOV36"])
)
return score
def rank_top(df, by, n=10, desc=True):
cols = ["Player", "Team", "GP", "MIN", by]
return df.sort_values(by=by, ascending=not desc)[cols].head(n)
def main():
ap = argparse.ArgumentParser()
ap.add_argument("csv", help="input stats CSV")
ap.add_argument("--min-gp", type=int, default=10)
ap.add_argument("--min-min", type=float, default=10.0)
ap.add_argument("--top", type=int, default=10)
ap.add_argument("--out", default=None, help="optional output CSV prefix")
args = ap.parse_args()
df = pd.read_csv(args.csv)
required = ["Player","Team","GP","MIN","PTS","REB","AST","STL","BLK","TOV","FGA","FGM","3PA","3PM","FTA","FTM"]
missing = [c for c in required if c not in df.columns]
if missing:
raise SystemExit(f"Missing columns: {missing}")
df = df[(df["GP"] >= args.min_gp) & (df["MIN"] >= args.min_min)].copy()
df["TS%"] = ts_pct(df) * 100
df["Score"] = build_score(df)
leaderboards = {
"Score": rank_top(df, "Score", args.top),
"PTS": rank_top(df, "PTS", args.top),
"REB": rank_top(df, "REB", args.top),
"AST": rank_top(df, "AST", args.top),
"STL": rank_top(df, "STL", args.top),
"BLK": rank_top(df, "BLK", args.top),
"TS%": rank_top(df, "TS%", args.top),
}
for name, tbl in leaderboards.items():
print(f"\n=== TOP {args.top} {name} ===")
print(tbl.to_string(index=False))
if args.out:
tbl.to_csv(f"{args.out}_{name}.csv", index=False, encoding="utf-8")
if __name__ == "__main__":
main()
想法与扩展

告诉我赛季与口径,或者把数据文件放到仓库里(路径+列名),我马上给你生成对应的排行榜。
