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

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)

def search_team_result_in_season(season, team):
    result = df[(df['Season'] == season) & ((df['AwayTeam'] == team) | (df['HomeTeam'] == team))][['League', 'Season', 'HomeTeam', 'AwayTeam', 'FTR', 'FTHG', 'FTAG']]
    return result

search_team_result_in_season('2012-2013', 'Real Madrid')