-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistical_analysis.py
More file actions
41 lines (31 loc) · 1.33 KB
/
Copy pathstatistical_analysis.py
File metadata and controls
41 lines (31 loc) · 1.33 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
class statistical_analysis:
def max_stats(df, col_list):
message = ''
for col in col_list:
stat = df[col].max()
name = df[df[col] == df[col].max()]["Name"].values[0]
message += name + ' has the greatest ' + col + ' stat of ' + str(stat) + '\n'
return message
def min_stats(df, col_list):
message = ''
for col in col_list:
stat = df[col].min()
name = df[df[col]==df[col].min()]['Name'].values[0]
message += name +' has the worst ' + col + ' stat of ' + str(stat) + '.\n'
return message
def barh_stats(df, types, colors):
import pandas as pd
import matplotlib.pyplot as plt
i = 0
plt.figure(figsize=(15,5))
plt.suptitle('Statistics', fontsize=15)
for t in types:
i+=1
plt.subplot(121)
plt.title('Mean')
pd.to_numeric(df[df['Type'] == t]).mean(axis = 0).plot(kind='barh', color = colors[i])
plt.subplot(122)
plt.title('Standard Deviation')
pd.to_numeric(df[df['Type'] == t]).std().plot(kind='barh', color = colors[i])
#Add list of Pokemon Type to legend
plt.legend(types, bbox_to_anchor=(1.3, 1.1))