text_plain_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)

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))

league_teams('Premier League')