ich want to replace values that differ more than 50% from my mean value by the vell before. The ocurring error is: "The truth value of an array with more than one element is ambigous. Use a.any() or a.all()."

Any ideas?

import csv

import pandas as pd

import numpy as np

from scipy import *

from numpy import *

import matplotlib.pyplot as plt

dF = pd.read_csv("Example.csv", sep=';')

xresult = []

#xresult = [abs(dF.x)]

xresult = dF.x.fillna(method = 'ffill') #bfill=backwardfill, ffill is filling the list with value before if na(=NaN)

xresult = [abs(xresult)]

print xresult

k=np.mean(xresult)

print k

print (np.std(xresult))

m = k*1.50

n = k*0,5t

print m

print n

for i in range(len(dF.x)):

if dF.x[i+1] > m:#if you compare a numpy array with a number you get another array

dF.x[i+1] = dF.x[i]

elsif:

if dF.x[i+1] < n:

dF.x[i+1] = dF.x[i]