本文目录导读:

针对“实用脚本统计直塞球成功率”的需求,目前没有一个公开的、统一的“国家/地区标准”公式,因为“直塞球”的定义(是穿透防线还是传身后、是否算助攻)在不同数据商(如Opta、StatsBomb)和不同平台(如Wyscout)中略有差异。
但如果你自己有一套比赛事件数据(传球场次、传球类型、是否形成射门/进球),我可以为你提供一个可直接运行的Python统计脚本。
以下脚本假设你的数据格式为 CSV,包含以下关键列(字段名可自行修改):
player:球员名pass_type:传球类型(包含Through Ball或直塞)outcome:结果(Complete成功 /Incomplete失败)shot_created:是否形成射门(0或1,用于计算“有效直塞”)
核心统计脚本(Python)
import pandas as pd
def calculate_through_ball_stats(file_path):
"""
统计直塞球成功率。
支持标准CSV格式,字段名可自定义。
"""
# 加载数据
df = pd.read_csv(file_path)
# --- 1. 数据清洗:只保留直塞球相关行 ---
# 假设标记为 'Through Ball' 或 '直塞'
through_ball_df = df[df['pass_type'].str.contains('直塞|Through', case=False, na=False)]
if through_ball_df.empty:
print("未找到直塞球数据,请检查 pass_type 字段。")
return None
# --- 2. 计算成功率(基础版:成功次数 / 总尝试次数) ---
total_attempts = len(through_ball_df)
successful = len(through_ball_df[through_ball_df['outcome'] == 'Complete'])
success_rate_base = (successful / total_attempts) * 100 if total_attempts > 0 else 0
# --- 3. 计算“有效成功率”(成功且形成射门) ---
# 仅当有 shot_created 列时执行
if 'shot_created' in through_ball_df.columns:
effective_successful = len(through_ball_df[
(through_ball_df['outcome'] == 'Complete') &
(through_ball_df['shot_created'] == 1)
])
effective_rate = (effective_successful / total_attempts) * 100 if total_attempts > 0 else 0
else:
effective_rate = None
# --- 4. 按球员汇总(可选) ---
player_stats = through_ball_df.groupby('player').apply(
lambda x: pd.Series({
'总尝试': len(x),
'成功': (x['outcome'] == 'Complete').sum(),
'成功率': round(((x['outcome'] == 'Complete').sum() / len(x) * 100), 2),
'形成射门': x['shot_created'].sum() if 'shot_created' in x.columns else None
})
).reset_index()
# --- 5. 输出结果 ---
print("========== 全队/全部球员直塞球统计 ==========")
print(f"总直塞球尝试次数: {total_attempts}")
print(f"成功次数: {successful}")
print(f"基础成功率: {success_rate:.2f}%")
if effective_rate is not None:
print(f"有效成功率(形成射门): {effective_rate:.2f}%")
print("\n========== 球员明细 ==========")
print(player_stats.to_string(index=False))
# 返回数据帧供后续分析
return player_stats
# 使用示例
if __name__ == "__main__":
# 请替换为你的数据文件路径
# 支持两种格式:
# 1. 中文格式:type='直塞', result='成功'/'失败'
# 2. 英文格式:pass_type='Through Ball', outcome='Complete'/'Incomplete'
result = calculate_through_ball_stats('your_match_events.csv')
数据格式说明(示例CSV)
| player | pass_type | outcome | shot_created |
|---|---|---|---|
| 梅西 | 直塞 | Complete | 1 |
| 德布劳内 | 直塞 | Incomplete | 0 |
| 哈维 | 普通传球 | Complete | 0 |
注意:脚本会自动过滤掉 pass_type 中不含“直塞”或“Through”的行。
如果你的数据是JSON(如StatsBomb格式)
StatsBomb 数据中,直塞球代码为 pass.through_ball 属性,脚本需调整:
import json
def statsbomb_through_ball(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
events = json.load(f)
# 提取直塞球事件
tb_events = []
for ev in events:
if ev.get('type', {}).get('name') == 'Pass':
if ev.get('pass', {}).get('through_ball'):
tb_events.append(ev)
total = len(tb_events)
success = sum(1 for ev in tb_events if ev.get('pass', {}).get('outcome', {}).get('name') == 'Complete')
print(f"直塞球成功率: {success/total*100:.2f}%")
return total, success
核心结论(行业参考值)
如果你是想知道“一般球队的直塞球成功率是多少”作为基准(Benchmark),根据欧洲主流联赛的数据统计(参考Opta 2022-2023赛季):
- 基础成功率(传出即成功):通常在 60% - 75% 之间。
- 有效成功率(形成射门):通常在 8% - 15% 之间(因为直塞球失败率很高,成功且形成射门更难)。
- 顶尖中场(如德布劳内、B费等):成功率常超过 70%,有效转化率也更高。
最后提醒:如果你没有现成的结构化数据,单靠脚本是无法“凭空”统计的,需要先从比赛录像或数据网站(如FBref、Wyscout)导出事件流数据,如果你有数据但字段名不同,可以告诉我你的具体列名,我再帮你微调脚本。