text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('/kaggle/input/euro-football-data-since-2012/Euro-Football_2012-2023.csv')

drop_index = []
for j in range(0, len(df)):
    if (pd.isnull(df['HomeTeam'][j]) == True) | (pd.isnull(df['FTHG'][j]) == True):
        drop_index.append(j)
df.drop(drop_index, axis=0, inplace=True)
df.reset_index(inplace=True)
df.drop('index', axis=1, inplace=True)
df.drop('id', axis=1, inplace=True)

import matplotlib.pyplot as plt
def league_teams(league):
    teams=[]
    for i in range(0,len(df)):
        if df['League'][i] == league:
            teams.append(df['HomeTeam'][i])
    team_counts = pd.DataFrame(data=teams, columns=['Teams']).value_counts()
    team_counts = team_counts.reset_index()
    column_name = '{} Teams most played since 2012'.format(league)
    team_counts.columns = [column_name, 'Counts']
    team_counts = team_counts.plot(kind='bar',x=column_name,stacked=True, figsize=(17,5))

def plot_team_result_in_season(season, team):
    home = df[(df['HomeTeam'] == team) & (df['Season'] == season)]['FTR'].value_counts()
    away = df[(df['AwayTeam'] == team) & (df['Season'] == season)]['FTR'].value_counts()
    ploting = pd.DataFrame([home, away], ['home', 'away'])

import seaborn as sns
def home_goals_in_season(team, season):
    date = []
    goals = []
    total_shots = []
    shot_target = []
    corners = []
    for i in range(0, len(df)):
        if (df['HomeTeam'][i] == team) & (df['Season'][i] == season):
            date.append(df['Date'][i])
            goals.append(df['FTHG'][i])
            total_shots.append(df['HS'][i])
            shot_target.append(df['HST'][i])
            corners.append(df['HC'][i])
        if i == len(df) - 1:
            goals_data = {'Date': date, 'Home goals': goals, 'Home total shots': total_shots, 'Home shot on target': shot_target, 'Home team corners': corners}
            home_goals = pd.DataFrame(goals_data).set_index('Date')
            sns.set_style('dark')

def away_goals_in_season(team, season):
    date = []
    goals = []
    total_shots = []
    shot_target = []
    corners = []
    for i in range(0, len(df)):
        if (df['AwayTeam'][i] == team) & (df['Season'][i] == season):
            date.append(df['Date'][i])
            goals.append(df['FTAG'][i])
            total_shots.append(df['AS'][i])
            shot_target.append(df['AST'][i])
            corners.append(df['AC'][i])
        if i == len(df) - 1:
            goals_data = {'Date': date, 'Away goals': goals, 'Away total shots': total_shots, 'Away shot on target': shot_target, 'Away team corners': corners}
            away_goals = pd.DataFrame(goals_data).set_index('Date')
            sns.set_style('dark')

away_goals_in_season('Barcelona', '2014-2015')