I have got the value of mean that is .0004 from the program given below.
dff = pd.read_csv("I01.csv")
avg = dff['A'].rolling(3).mean()
dff['I_mean'] = avg
window = []
listpos = 0
for datapoint in dff.A:
mean = dff.I_mean[listpos]
print(mean)
if (datapoint < mean) and (len(window) < 1):
listpos += 1
After simulation the program if statement is not working. It shows error.
A 0.0004
dtype: float64
ValueError Traceback (most recent call last)
<ipython-input-12-49a6c73fdd23> in <module>()
74 mean = dff.I_mean[listpos]
75 print(mean)
---> 76 if (datapoint < mean) & (len(window) < 1):
77 listpos += 1
~\AppData\Roaming\Python\Python37\site-packages\pandas\core\generic.py in __nonzero__(self)
1328 def __nonzero__(self):
1329 raise ValueError(
-> 1330 f"The truth value of a {type(self).__name__} is ambiguous. "
1331 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
1332 )
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
.0004 is the mean value. If I put this mean value (.0004) directly on the code then my program shows no error. Why it's happening? What's wrong in the code?