-
Notifications
You must be signed in to change notification settings - Fork 0
/
Major_analyze.py
79 lines (65 loc) · 2.19 KB
/
Major_analyze.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""
Author : wumaomao
Time : 2020.03.23
Address : Wuchuan
Environment : windows10 python3.7 Anaconda3
Function : exposing major-data visible
"""
import sys
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
if __name__ == '__main__':
try:
data_frame = pd.read_excel('2017级专业分流录取名次对照表-简版.xlsx')
rank = data_frame['名次 '].tolist()
grade = data_frame['总平均加权成绩 '].tolist()
major = data_frame['录取专业'].tolist()
except Exception:
print('data file is not right')
sys.exit(-1)
# Dividing four parts
Optic = []
Optic_grade = []
Integrate = []
Integrate_grade = []
Micro = []
Micro_grade = []
Elc = []
Elc_grade = []
for i in range(0, len(rank)):
if major[i] == '光电':
Optic.append(rank[i])
Optic_grade.append(grade[i])
elif major[i] == '集成':
Integrate.append(rank[i])
Integrate_grade.append(grade[i])
elif major[i] == '微电子':
Micro.append(rank[i])
Micro_grade.append(grade[i])
elif major[i] == '电子':
Elc.append(rank[i])
Elc_grade.append(grade[i])
else:
print('error:')
print(rank[i])
print('Grade of Optic : %f' % (sum(Optic_grade)/len(Optic_grade)))
print('Grade of Integrate : %f' % (sum(Integrate_grade)/len(Integrate_grade)))
print('Grade of Micro : %f' % (sum(Micro_grade)/len(Micro_grade)))
print('Grade of Elc : %f' % (sum(Elc_grade)/len(Elc_grade)))
print(Micro)
# data -> visible
fig = plt.figure()
list1 = [0] * len(Optic)
list2 = [5] * len(Integrate)
list3 = [10] * len(Micro)
list4 = [15] * len(Elc)
ax = Axes3D(fig)
plt.xlabel('Rank')
plt.ylabel('Grade')
ax.scatter3D(Optic, Optic_grade, list1, label='Optic')
ax.scatter3D(Integrate, Integrate_grade, list2, label='Integrate')
ax.scatter3D(Micro, Micro_grade, list3, label='Micro')
ax.scatter3D(Elc, Elc_grade, list4, label='Elc')
plt.legend()
plt.show()