+ 1

where is the error ? python for data science project 2

import numpy as np data = np.array([150000, 125000, 320000, 540000, 200000, 120000, 160000, 230000, 280000, 290000, 300000, 500000, 420000, 100000, 150000, 280000]) SD=np.std(data) MEAN=np.mean(data) c=SD+MEAN d=SD-MEAN low, high = d,c count = len([v for v in data if low < v < high]) print(count*100/len(data))

23rd Mar 2021, 6:08 PM
Aayush Adhikari
Aayush Adhikari - avatar
3 Respostas
+ 2
I think I use d = MEAN - SD
23rd Mar 2021, 6:24 PM
Paul
Paul - avatar
0
Paul is right. A much more minor improvement would be to eliminate your c and d variables and just directly store into high and low like the following: SD=np.std(data) MEAN=np.mean(data) high=MEAN+SD low=MEAN-SD count = len([v for v in data if low < v < high]) print(count*100/len(data)) The c and d variables make the code slightly less readable.
23rd Mar 2021, 6:30 PM
Josh Greig
Josh Greig - avatar
0
thanks man!!
23rd Mar 2021, 7:44 PM
Aayush Adhikari
Aayush Adhikari - avatar