dimanche 31 janvier 2021

KeyError even though columns exist?

I'm trying to create an And statement in my for loop. There is a data frame that I have under "b". There are two columns of the data frame that I isolated into their respective lists (cdr3_length and heavy_percent).

I'm trying to create a for loop where the it parses through b and adds all data where the cdr3_length > 15 and heavy_percent < 88 to a new list "candidates".

cdr3_length=marv["heavy_cdr3_aa_length"]
cdr3_length.head()
heavy_percent=marv["heavy_percent_id"]
heavy_percent.head()

cnt_=0
candidates=[]
for i in range(0, len(b)):
    if (cdr3_length(b[i]) > 15) and (heavy_percent(b[i]) < 88):
        candidates.append(b[i])
    
        cnt+=1

Unfortunately, I'm receiving a KeyError:0 even though my columns exist and both .head() functions work. It says the error appears in the if statement line. I appreciate any help given, thank you!

Aucun commentaire:

Enregistrer un commentaire