-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalysis.py
56 lines (36 loc) · 1.11 KB
/
Analysis.py
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
# Create Correlation Plots of Data
# library
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
# DataSet
df = pd.read_csv("Lahman_Batting_Combined.csv")
df = df[df['yearID']>2014]
df = df[df['AB']>100]
df = df[['H', 'HR', 'SB', 'RBI', 'Team_W', 'teamID']]
print(df.head())
print(df.shape)
print("Dataset: Success")
# Create Plot
fig1 = sns.pairplot(df, kind="reg", diag_kind="hist", hue="teamID", palette="Set2")
# plt.show()
print("Successful Plot")
fig1.savefig('images/batting_correlation_plot_2015-2020.png')
print("Plot Saved Successful")
print("File Complete")
# DataSet
df = pd.read_csv("Lahman_Pitching_Combined.csv")
df = df[df['yearID']>2014]
df = df[df['IPouts']>120]
df = df[['GS', 'IPouts', 'ER', 'BB', 'SO', 'ERA', 'teamID']]
print(df.head())
print(df.shape)
print("Dataset: Success")
# Create Plot
fig2 = sns.pairplot(df, kind="reg", diag_kind="hist", hue="teamID", palette="Set2")
# plt.show()
print("Successful Plot")
fig2.savefig('images/pitching_correlation_plot_2015-2020.png')
print("Plot Saved Successful")
print("File Complete")