In [1]:
#loading the required libraries
import pandas as pd
from matplotlib import pyplot as plt
#import seaborn as sns
In [2]:
#loading the serie A dataset
sra=pd.read_csv('table_serie_2022-23.csv')
In [3]:
#having a glance at top 5 records of the dataset
sra.head()
Out [3]:
Team Position PL W D L GD PTS
0 Napoli 1 27 23 2 2 48 71
1 Lazio 2 27 15 7 5 23 52
2 Inter 3 27 16 2 9 16 50
3 Milan 4 27 14 6 7 8 48
4 Roma 5 27 14 5 8 9 47
In [4]:
#Looking at the number of rows(no. of teams) and columns in dataset
sra.shape
Out [4]:
(20, 8)
In [5]:
#Extracting the records where a team has positive GD.
sra[sra['GD']>=0]
Out [5]:
Team Position PL W D L GD PTS
0 Napoli 1 27 23 2 2 48 71
1 Lazio 2 27 15 7 5 23 52
2 Inter 3 27 16 2 9 16 50
3 Milan 4 27 14 6 7 8 48
4 Roma 5 27 14 5 8 9 47
5 Atalanta 6 27 13 6 8 13 45
6 Juventus 7 27 17 5 5 23 41
7 Udinese 8 27 9 11 7 6 38
8 Fiorentina 9 27 10 7 10 1 37
In [6]:
plt.bar(list(sra['PTS'][0:5].keys()),list(sra['PTS'][0:5]),color=["deepskyblue","cornflowerblue","blue","red","maroon"])
plt.xticks([0, 1, 2, 3, 4], ['NAP', 'LAZ', 'INT','MIL','ROM'])
plt.xlabel('Teams')
plt.ylabel('Prices')
plt.show()
In [7]:
#Teams going to the champions league
sra[0:4]
Out [7]:
Team Position PL W D L GD PTS
0 Napoli 1 27 23 2 2 48 71
1 Lazio 2 27 15 7 5 23 52
2 Inter 3 27 16 2 9 16 50
3 Milan 4 27 14 6 7 8 48
In [8]:
#Team going to the europa league
sra[4:5]
Out [8]:
Team Position PL W D L GD PTS
4 Roma 5 27 14 5 8 9 47
In [9]:
#Team going to the Conference league
sra[5:6]
Out [9]:
Team Position PL W D L GD PTS
5 Atalanta 6 27 13 6 8 13 45
In [10]:
#Team getting to relegated to Serie B league
sra[-3:]
Out [10]:
Team Position PL W D L GD PTS
17 Hellas Verona 18 27 4 7 16 -19 19
18 Sampdoria 19 27 3 6 18 -28 15
19 Cremonese 20 27 1 10 16 -27 13
In [11]:
#loading the serie A events dataset
esra=pd.read_csv('events_serie_2022-23.csv')
In [12]:
esra.head()
Out [12]:
event_id match_id team event_team event_time event_type action_player_1 action_player_2
0 1 1 Juventus away 23 Goal Filip Kostić Adrien Rabiot
1 2 1 Inter home 30 Yellow card Nicolo Barella NaN
2 3 1 Juventus away 31 Yellow card Federico Gatti NaN
3 4 1 Inter home 63 Substitution Danilo D'Ambrosio Federico Dimarco
4 5 1 Inter home 63 Substitution Henrikh Mkhitaryan Nicolo Barella
In [17]:
esra[esra['event_type'].str.contains('Goal')]
Out [17]:
event_id match_id team event_team event_time event_type action_player_1 action_player_2
0 1 1 Juventus away 23 Goal Filip Kostić Adrien Rabiot
23 24 2 Lazio home 65 Goal Mattia Zaccagni NaN
37 38 3 Napoli away 9 Goal Victor Osimhen Piotr Zieliński
40 41 3 Napoli away 51 Goal Victor Osimhen Mathías Olivera
46 47 3 Napoli away 68 Goal Tanguy Ndombele Khvicha Kvaratskhelia
... ... ... ... ... ... ... ... ...
4487 4488 269 Udinese away 2 Goal Rodrigo Becão Gerard Deulofeu
4490 4491 269 Milan home 15 Goal Ante Rebic Davide Calabria
4493 4494 269 Udinese away 49 Goal Adam Masina Roberto Pereyra
4494 4495 269 Milan home 46 Goal Brahim Diaz NaN
4498 4499 269 Milan home 68 Goal Ante Rebic Brahim Diaz

600 rows × 8 columns

In [37]:
esra[(esra['team'] == 'Napoli')]
Out [37]:
event_id match_id team event_team event_time event_type action_player_1 action_player_2
37 38 3 Napoli away 9 Goal Victor Osimhen Piotr Zieliński
39 40 3 Napoli away 35 Penalty Khvicha Kvaratskhelia Penalty
40 41 3 Napoli away 51 Goal Victor Osimhen Mathías Olivera
44 45 3 Napoli away 65 Substitution Eljif Elmas Hirving Lozano
45 46 3 Napoli away 65 Substitution Tanguy Ndombele Piotr Zieliński
... ... ... ... ... ... ... ... ...
4360 4361 261 Napoli away 79 Goal Matteo Politano Victor Osimhen
4361 4362 261 Napoli away 83 Substitution Mathías Olivera Mario Rui
4362 4363 261 Napoli away 83 Substitution Adam Ounas Victor Osimhen
4363 4364 261 Napoli away 84 Disallowed goal Disallowed goal NaN
4364 4365 261 Napoli away 93 Yellow card Kim Min-jae NaN

234 rows × 8 columns

In [ ]: