Array mit Zahl vergleichen
Verfasst: Montag 12. August 2013, 07:18
Ich möchte Werte, die mehr als 50% von meinem Mittelwert abweichen duch den Wert der Zelle vorher ersetzen. Ich bekomme dann den Fehler: "The truth value of an array with more than one element is ambiogus. Use a.any() or a.all()."
Kann jemand helfen?
Kann jemand helfen?
Code: Alles auswählen
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]