text_html_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/fifa-world-cup-2022/international_matches.csv')

pd.set_option('display.max_columns', None)

df.describe().T

num_cols = list(df.select_dtypes(include=['int64', 'float64']).columns)
cat_cols = list(df.select_dtypes(include=['object']).columns)

columns_contains_null = [col for col in df.columns if df[col].isnull().any()]

fifa2022_teams = ['Qatar', 'Ecuador', 'Senegal', 'Netherlands', 'England', 'IR Iran', 'USA', 'Wales', 'Argentina', 'Saudi Arabia', 'Mexico', 'Poland', 'France', 'Australia', 'Denmark', 'Tunisia', 'Spain', 'Costa Rica', 'Germany', 'Japan', 'Belgium', 'Canada', 'Morocco', 'Croatia', 'Brazil', 'Serbia', 'Switzerland', 'Cameroon', 'Portugal', 'Ghana', 'Uruguay', 'Korea Republic']

ranks = []
for x in fifa2022_teams:
    rank_df = df[(df['home_team'] == x) | (df['away_team'] == x)].sort_values(['date', 'home_team_fifa_rank', 'away_team_fifa_rank'], ascending=[False, True, True]).iloc[0]
    if rank_df['home_team'] == x:
        rank = rank_df['home_team_fifa_rank']
    else:
        rank = rank_df['away_team_fifa_rank']
    ranks.append(rank)
team_ranks = pd.DataFrame({'Team': fifa2022_teams, 'Rank': ranks}).sort_values('Rank').reset_index(drop=True)
team_ranks.index += 1
team_ranks

goalkeeper_score = []
for x in fifa2022_teams:
    gk_score = np.round((df[df['home_team'] == x]['home_team_goalkeeper_score'].mean() + df[df['away_team'] == x]['away_team_goalkeeper_score'].mean()) / 2, 2)
    goalkeeper_score.append(gk_score)
goalkeeper_scores = pd.DataFrame({'Team': fifa2022_teams, 'Gk score': goalkeeper_score}).sort_values('Gk score', ascending=False).reset_index(drop=True)
goalkeeper_scores.index += 1
goalkeeper_scores

plt.figure(figsize=(11,7), dpi=90)
ax = sns.barplot(data=goalkeeper_scores[:10], x='Team', y='Gk score')
ax.bar_label(ax.containers[0])
plt.xlabel('TEAM')
plt.ylabel('SCORE')
plt.title('TOP 10 GOALKEEPER SCORE');

defence_score = []
for x in fifa2022_teams:
    df_score = np.round((df[df['home_team'] == x]['home_team_mean_defense_score'].mean() + df[df['away_team'] == x]['away_team_mean_defense_score'].mean()) / 2, 2)
    defence_score.append(df_score)
defence_scores = pd.DataFrame({'Team': fifa2022_teams, 'Df score': defence_score}).sort_values('Df score', ascending=False).reset_index(drop=True)
defence_scores.index += 1
defence_scores

plt.figure(figsize=(11, 7), dpi=90)
ax = sns.barplot(data=defence_scores[:10], x='Team', y='Df score')
ax.bar_label(ax.containers[0])
plt.xlabel('TEAM')
plt.ylabel('SCORE')
plt.title('TOP 10 STRONGEST DEFENCE')