I have a .csv file of 2289 datapoints, with the first ten being :
[1071936.0, 1231944.0, 1391953.0, 1551957.0, 1711960.0, 1711961.0, 1871964.0, 2031968.0, 2031969.0, 2191973.0]
On row 5 and 6, there are two data points who are only 1 data point away from each other. Since the array is sorted from smallest to largest, I want to see if element X and element X 1 are within 80 data points of each other. If they are, then remove element X 1.
n = 0
y = []
for k in range(10):
y = duplicates_removed_tr_sc
window = duplicates_removed_tr_sc[n]
for x in range(80):
if(duplicates_removed_tr_sc[k]== duplicates_removed_tr_sc[n]):
del y[k 1] #delete the k 1 element if it is
window = window 1
y = np.asarray(y)
y = sorted(y)
This is what I tried but it's not giving me a valid outcome :/ would appreciate any help!
CodePudding user response:
It's always best to create a NEW list with the data you want to keep.
keep = []
last = -9999
for value in datapoints:
if value - last > 80:
keep.append(value)
last = value
keep = np.asarray(keep)