Hi I have a large data file and I'm only interested in rows with specific x values of 4.125 as shown below. Now because the value of 4.125 relates to the stop position of the ion, the corresponding start position is also of interest to me and I want to keep this information in the array. How do I write a program which effectively finds the x stop position of 4.125 and retains the ion start position? I have attached the data file I'm using.
This is the code I have developed so far but does not work:
This is the code I have developed so far but does not work:
Code:
import pandas as pd
import numpy as np
opts = pd.read_csv('Ambre_2.dat',sep = ',', low_memory = False)
df = pd.DataFrame(opts)
X = df.iloc[:,3]
IonN = df.iloc[:,0]
tol = 1e-6
Fltr = 4.125
filterreddata = df[abs(df.X-Fltr)<tol,:]
filteredions = df(np.in1d(df.IonN, filterreddata.IonN), :]
filteredions[2:2:end, :] = []
f = open('ions.csv', 'w')
f.write(tabulate(filteredions))
f.close()
Comment