Nov-24-2019, 08:02 PM
So I used this appraoch below:
How can I get the average points and pick teams that have finished first?
Sample data at the very bottom
# Purpose: Inputing data from a csv file
# Example of: File input from a csv file, using a dictionary
print("This program loads all historic premier league data")
# start with an empty dictionary
# dictionary keys will be the (Pos, Club)
premier = {}
print()
print("Historic premier league")
# open the file
with open(r"Historic_PL.csv") as data_file:
# read in the first line containing the headers
headers = data_file.readline()
# for each other line in the file
for line in data_file:
# split each line into components (remove white space from ends of line)
Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best = line.strip().split(",")
# insert the data into the dictionary
premier[(int(Pos), Club)] = (int(Seasons),int(Pld),int(Win),int(Draw),int(Loss),int(GF),int(GA),int(GD),int(Pts),int(First),int(Second),int(Third),int(Fourth),int(Relegated),int(Best))
print(f"Number of values: {len(premier)}")
################################################################
Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best
1,Manchester United,27,1038,648,224,166,1989,929,1060,2168,13,6,3,1,0,1
2,Arsenal,27,1038,565,260,213,1845,1013,832,1955,3,6,5,7,0,1
3,Chelsea,27,1038,558,257,223,1770,1002,768,1931,5,4,5,2,0,1
4,Liverpool,27,1038,529,262,247,1774,1046,728,1849,0,4,5,7,0,2
5,Tottenham Hotspur,27,1038,446,257,335,1547,1306,241,1595,0,1,2,3,0,2
6,Everton,27,1038,377,296,365,1357,1311,46,1427,0,0,0,1,0,4
7,Manchester City,22,848,391,196,261,1374,975,399,1369,4,2,2,1,2,1
How can I get the average points and pick teams that have finished first?
Sample data at the very bottom
# Purpose: Inputing data from a csv file
# Example of: File input from a csv file, using a dictionary
print("This program loads all historic premier league data")
# start with an empty dictionary
# dictionary keys will be the (Pos, Club)
premier = {}
print()
print("Historic premier league")
# open the file
with open(r"Historic_PL.csv") as data_file:
# read in the first line containing the headers
headers = data_file.readline()
# for each other line in the file
for line in data_file:
# split each line into components (remove white space from ends of line)
Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best = line.strip().split(",")
# insert the data into the dictionary
premier[(int(Pos), Club)] = (int(Seasons),int(Pld),int(Win),int(Draw),int(Loss),int(GF),int(GA),int(GD),int(Pts),int(First),int(Second),int(Third),int(Fourth),int(Relegated),int(Best))
print(f"Number of values: {len(premier)}")
################################################################
Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best
1,Manchester United,27,1038,648,224,166,1989,929,1060,2168,13,6,3,1,0,1
2,Arsenal,27,1038,565,260,213,1845,1013,832,1955,3,6,5,7,0,1
3,Chelsea,27,1038,558,257,223,1770,1002,768,1931,5,4,5,2,0,1
4,Liverpool,27,1038,529,262,247,1774,1046,728,1849,0,4,5,7,0,2
5,Tottenham Hotspur,27,1038,446,257,335,1547,1306,241,1595,0,1,2,3,0,2
6,Everton,27,1038,377,296,365,1357,1311,46,1427,0,0,0,1,0,4
7,Manchester City,22,848,391,196,261,1374,975,399,1369,4,2,2,1,2,1