-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
116 lines (94 loc) · 3.04 KB
/
main.py
File metadata and controls
116 lines (94 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
import json
import pandas as pd
import matplotlib.pyplot as plot
import seaborn as sns
#Get the timePlayed, pointsScored, number of games played for each player
#Displays a plot of the average points scored per time played for each player
def function1():
#Get the data from the json file
with open('playerData.json') as f:
data = json.load(f)
#Get the timePlayed, pointsScored, number of games played for each player
timePlayed = []
pointsScored = []
gamesPlayed = []
for player in data:
timePlayed.append(data[player]['MIN'])
pointsScored.append(data[player]['PTS'])
print(data[player])
print('\n')
print(timePlayed)
print('\n')
print(pointsScored)
#Plot the average points scored per time played for each player
plot.plot(timePlayed, pointsScored, 'ro')
plot.xlabel('Time Played')
plot.ylabel('Average Points Scored')
plot.title('Average Points Scored per Time Played')
#make index ascending
plot.gca().invert_xaxis()
plot.gca().invert_yaxis()
plot.xticks([0,50,100,150,200,250])
plot.yticks([0,50,100,150,200,250])
plot.show()
return
def function2():
df=pd.read_csv('playerData.csv')
sns.heatmap(df[['3PM','AST']].corr(method='pearson'),annot=True)
plot.show()
return
def function3():
df=pd.read_csv('playerData.csv')
sns.scatterplot(x="FTM", y="PTS", hue="Team", data=df)
plot.show()
return
def function4():
df=pd.read_csv('teamData.csv')
sns.jointplot(x="3PM", y="3PA", data=df, kind="kde")
plot.show()
return
def function5():
df=pd.read_csv('playerData.csv')
sns.kdeplot(x="FGA", y="REB", data=df[df['Team']=='UTA']) #Dunk essayés et Rebond
#define x axe title as "Dunk essayés"
plot.xlabel("Dunks attempted")
#define y axe title as "Rebond"
plot.ylabel("Team rebounds")
plot.show()
return
def main():
StillActive = True
while(StillActive):
print("\nWelcome to our Python Scripting project! What data would you like to see?")
print("1. Players Points goals per time played")
print("2. 3 points scored per team based on assists")
print("3. Points scored by team based on free throws scored")
print("4. 3points attempted per team based on 3points scored")
print("5. Team rebounds based on dunks attempted")
print("6. Get Data")
print("7. Exit")
choice = input("Enter your choice: ")
if choice == "1":
print('\n')
function1()
elif choice == "2":
print('\n')
function2()
elif choice == "3":
print('\n')
function3()
elif choice == "4":
print('\n')
function4()
elif choice == "5":
print('\n')
function5()
elif choice == "6":
StillActive = False
elif choice == "7":
StillActive = False
else :
print('\n')
print("Invalid choice")
main()