I have the following data in a tab-separated file test.tsv.
Class Length Frag
I 100 True
I 200 True
P 300 False
I 400 False
P 500 True
P 600 True
N 700 True
I have loaded the data into a pandas.DataFrame object, and anywhere that Class = I and Frag = True I would like to set Class = F. The following code does not seem to be working. What am I doing wrong, and what should I be doing?
import pandas
data = pandas.read_table('test.tsv')
data.loc[(data.Class == 'I') & (data.Frag is True), 'Class'] = 'F'