I have a very annoying set of measurments, and ever so often it just blibs and has a very high values followed by a very low one compared to the normal pattern.
I'm trying to get rid of these and was wondering if there was a way to take away the previous point efficently and if thats greater than (for arbitary sake 20) to delete both points:
This is what I have so far but I have a huge data set so want to avoid for loops
for i in range(1,len(df1)):
if abs(df1[TYPE].loc[i]-df1[TYPE].loc[i-1])>20:
#update new columns
df1[TYPE].loc[i-1] = -9999;
df1[TYPE].loc[i] =-9999;
where TYPE is the name of my column variable This method also says:
TypeError: cannot do index indexing on <class `'pandas.tseries.index.DatetimeIndex'> with these indexers [1] of <class 'int'>`
I was also thinking somthing on these liens was an option- but Im not sure how to adapt it so it wouldn't do the whole dataframe in one go but compare each location
df1.insert(0,"newcol1","-9999")
df1['newcol1'] = df1[TYPE].shift() == df1[TYPE]
df1.ix[0, 'newcol1'] = True
if df1[['newcol1']] > 50:
print("Jhrjhfh!")
df1[TYPE]=-9999
df1[TYPE].shift=-9999