This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#let's put the csv files into dataframes using pandas | |
tables_15_16 = pd.read_csv("Tables 2015-16.csv") | |
tables_16_17 = pd.read_csv("Tables 2016-17.csv") | |
tables_17_18 = pd.read_csv("Tables 2017-18.csv") | |
tables_18_19 = pd.read_csv("Tables 2018-19.csv") | |
tables_19_20 = pd.read_csv("Tables 2019-20.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Having a look at the dataframe structure (they have the same structure) | |
tables_15_16.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
premier_league_15_16 = tables_15_16.loc[(tables_15_16["League"] == "Premier League") & (tables_15_16["Table Type"] == "League Table")] | |
premier_league_16_17 = tables_16_17.loc[(tables_16_17["League"] == "Premier League") & (tables_16_17["Table Type"] == "League Table")] | |
premier_league_17_18 = tables_17_18.loc[(tables_17_18["League"] == "Premier League") & (tables_17_18["Table Type"] == "League Table")] | |
premier_league_18_19 = tables_18_19.loc[(tables_18_19["League"] == "Premier League") & (tables_18_19["Table Type"] == "League Table")] | |
premier_league_19_20 = tables_19_20.loc[(tables_19_20["League"] == "Premier League") & (tables_19_20["Table Type"] == "League Table")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
premier_league_19_20 = pd.read_csv("https://raw.githubusercontent.com/davisvictorns/data_science/main/premierLeague19_20.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
premier_league_test = pd.concat([premier_league_15_16, premier_league_19_20], ignore_index=True) | |
premier_league_test.tail() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
premier_league_19_20["Season"] = "2019/20" | |
premier_league_19_20.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
premier_league_all = pd.concat([premier_league_15_16, | |
premier_league_16_17, | |
premier_league_17_18, | |
premier_league_18_19, | |
premier_league_19_20], axis=0, ignore_index=True) | |
premier_league_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#excluding unecessary columns | |
premier_league_all.drop(["League", "Table Type", "KEY"], axis=1, inplace=True) | |
#renaming columns | |
premier_league_all.columns = ["position", "team", "games_played", "wins", "draws", "losts", "goals_for", "goals_against", "goals_difference", "points", "season"] | |
#transforming some columns to 'int64' type | |
premier_league_all = premier_league_all.astype({'position': 'int64', 'wins': 'int64', 'draws': 'int64', 'losts': 'int64'}) | |
premier_league_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.style.use("fivethirtyeight") |
OlderNewer