import pandas as pd
from pandas import DataFrame
import math as ma
df = pd.read_csv("/Users/aaronhuang/Desktop/ffp/exfileCLEAN.csv")
df_top = df.head()
num = pd.read_csv('/Users/aaronhuang/Desktop/ffp/exfileCLEAN.csv', usecols=[1])
stand = round(num.std(), 4)
conf = stand * 3
avgs = round(num.mean(), 4)
avg = 19.31322603
ran = 0.425812854
i = 0
while(i < len(df['Magnitude '])):
if(abs(df['Magnitude '][i] - avgs) > conf):
print(df['Magnitude '][i])
i += 1
When I try and run this, it gives me:
Traceback (most recent call last):
File "/Users/aaronhuang/PycharmProjects/EXTTEst/Code sandbox.py", line 18, in <module>
if(abs(df['Magnitude '][i] - avgs) > conf):
File "/Users/aaronhuang/.conda/envs/EXTTEst/lib/python3.8/site-
packages/pandas/core/generic.py", line 1478, in __nonzero__
raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(),
a.any() or a.all().
Process finished with exit code 1
How can I fix this so I do not get this error anymore? Also When it prints the Values at the end, is there a way can I have it print out the cell in the first column in the CSV instead.
Any help would be greatly appreciated.
Thanks