-
Notifications
You must be signed in to change notification settings - Fork 1
/
RATIO.py
65 lines (48 loc) · 1.56 KB
/
RATIO.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
''' Comparing the ratio of total profit to the units sold for each region '''
import numpy as np
''' include the proper directory of the file'''
f=open('C:\\Users\\user\\Desktop\\important\\csv\\sales.csv','r')
w=[]
q=[]
SS=[]
AO=[]
CC=[]
EU=[]
A=[]
MEA=[]
e=f.read().splitlines()
for i in range(1,len(e)):
t=e[i].split(',')
w=t[8]
q=t[13]
x=t[0]
if(x=='Sub-Saharan Africa'):
SS.append(float(q)/float(w))
elif(x=='Australia and Oceania'):
AO.append(float(q)/float(w))
elif(x=='Central America and the Caribbean'):
CC.append(float(q)/float(w))
elif(x=='Europe'):
EU.append(float(q)/float(w))
elif(x=='Asia'):
A.append(float(q)/float(w))
else:
MEA.append(float(q)/float(w))
meanSS=np.mean(SS)
meanAO=np.mean(AO)
meanCC=np.mean(CC)
meanEU=np.mean(EU)
meanA=np.mean(A)
meanMEA=np.mean(MEA)
if(meanSS>meanAO and meanSS>meanCC and meanSS>meanEU and meanSS>meanA and meanSS>meanMEA):
print(meanSS)
elif(meanAO>meanSS and meanAO>meanCC and meanAO>meanEU and meanAO>meanA and meanAO>meanMEA):
print(meanAO)
elif(meanCC>meanSS and meanCC>meanAO and meanCC>meanEU and meanCC>meanA and meanCC>meanMEA):
print(meanCC)
elif(meanEU>meanSS and meanEU>meanAO and meanEU>meanCC and meanEU>meanA and meanEU>meanMEA):
print(meanEU)
elif(meanA>meanSS and meanA>meanCC and meanA>meanEU and meanA>meanAO and meanA>meanMEA):
print(meanA)
else:
print(meanMEA)