Skip to content

Instantly share code, notes, and snippets.

View chukwujekwu-code's full-sized avatar

Chukwujekwu chukwujekwu-code

View GitHub Profile
# checking the number of different nationalities represented in the league
np.size(df['nationality'].unique())
# Bottom 10 least scoring teams in the league
least_scoring_teams = goals_scoredby_teams.nsmallest(n = 10)
least_scoring_teams.plot(kind = 'bar', figsize = (8,5))
plt.title('Bottom 10 Least Scoring Clubs')
plt.xlabel('Clubs')
plt.ylabel('Goals Scored');
top_scoring_teams.plot(kind = 'bar', figsize = (8,5))
plt.title('Top 10 Highest Scoring Clubs')
plt.xlabel('Clubs')
plt.ylabel('Goals Scored');
# create a pie chart showing the proportion of penalty missed and penalty scored
plt.figure(figsize = (13,6))
data = [total_penalty_scored, total_penalty_missed]
plt.title(' Proportion of Penalty Scored against Penalty Missed')
keys = ['Penalties Scored', 'Penalties missed']
explode = [0, 0.1]
color = sns.color_palette('dark')
plt.pie(data, labels = keys , colors = color , explode = explode, autopct = '%.0f%%');
# which team scored the most goals
goals_scoredby_teams = df.groupby('club')['goals'].sum().sort_values(ascending = False)
goals_scoredby_teams
# Total goals scored in the season
total_goals = df['goals'].sum()
total_goals
# View the information on the dataset
df.info()
# View random 20 rows
df.sample(20)
# View the bottom 20 rows
df.tail(20)
# View the first 20 rows
df.head(20)