Corner Kicks and Free Kicks Analysis
Beginner
10 min read
0 views
Nov 27, 2025
# Overview
Evaluate set-piece effectiveness through statistical analysis of corner kicks, free kicks, and scoring patterns.
## Python Implementation
```python
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# Load set-piece data
set_pieces = pd.read_csv('set_pieces.csv')
# Analyze corner kick outcomes
corner_analysis = set_pieces[set_pieces['type'] == 'corner'].groupby('delivery_zone').agg({
'shot_created': 'sum',
'goal': 'sum',
'event_id': 'count'
}).rename(columns={'event_id': 'total_corners'})
corner_analysis['conversion_rate'] = (corner_analysis['goal'] / corner_analysis['total_corners']) * 100
corner_analysis['shot_rate'] = (corner_analysis['shot_created'] / corner_analysis['total_corners']) * 100
print("Corner Kick Analysis by Delivery Zone:")
print(corner_analysis)
# Free kick distance vs success rate
free_kicks = set_pieces[set_pieces['type'] == 'free_kick']
free_kicks['distance_bin'] = pd.cut(free_kicks['distance'], bins=[0, 20, 25, 30, 35, 50],
labels=['0-20m', '20-25m', '25-30m', '30-35m', '35m+'])
fk_success = free_kicks.groupby('distance_bin').agg({
'on_target': 'sum',
'goal': 'sum',
'event_id': 'count'
}).rename(columns={'event_id': 'total_attempts'})
fk_success['accuracy_rate'] = (fk_success['on_target'] / fk_success['total_attempts']) * 100
fk_success['conversion_rate'] = (fk_success['goal'] / fk_success['total_attempts']) * 100
# Visualize
plt.figure(figsize=(10, 6))
fk_success[['accuracy_rate', 'conversion_rate']].plot(kind='bar')
plt.title('Free Kick Performance by Distance')
plt.ylabel('Percentage (%)')
plt.xlabel('Distance Range')
plt.legend(['Accuracy Rate', 'Conversion Rate'])
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
```
## R Implementation
```r
library(dplyr)
library(ggplot2)
library(tidyr)
# Load set-piece data
set_pieces <- read.csv("set_pieces.csv")
# Corner kick analysis
corner_analysis <- set_pieces %>%
filter(type == "corner") %>%
group_by(delivery_zone) %>%
summarise(
total_corners = n(),
shots_created = sum(shot_created),
goals = sum(goal),
conversion_rate = (goals / total_corners) * 100,
shot_rate = (shots_created / total_corners) * 100,
.groups = "drop"
)
print("Corner Kick Analysis by Delivery Zone:")
print(corner_analysis)
# Free kick analysis by distance
free_kicks <- set_pieces %>%
filter(type == "free_kick") %>%
mutate(distance_bin = cut(distance,
breaks = c(0, 20, 25, 30, 35, 50),
labels = c("0-20m", "20-25m", "25-30m", "30-35m", "35m+")))
fk_success <- free_kicks %>%
group_by(distance_bin) %>%
summarise(
total_attempts = n(),
on_target = sum(on_target),
goals = sum(goal),
accuracy_rate = (on_target / total_attempts) * 100,
conversion_rate = (goals / total_attempts) * 100,
.groups = "drop"
)
# Visualize
fk_success %>%
select(distance_bin, accuracy_rate, conversion_rate) %>%
pivot_longer(cols = c(accuracy_rate, conversion_rate),
names_to = "metric",
values_to = "percentage") %>%
ggplot(aes(x = distance_bin, y = percentage, fill = metric)) +
geom_bar(stat = "identity", position = "dodge") +
labs(
title = "Free Kick Performance by Distance",
x = "Distance Range",
y = "Percentage (%)"
) +
theme_minimal()
```
Discussion
Have questions or feedback? Join our community discussion on
Discord or
GitHub Discussions.
Table of Contents
Related Topics
Quick Actions