+ 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))
3 Answers
+ 2
I think I use d = MEAN - SD
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.
0
thanks man!!