mercredi 18 mars 2020

Why this cycle return me anything?

I import a dataframe with pandas, extract the last column (the labels one) and try to build two count variable to understand how many data I have with the two labels. The code is this:

def apply_transformation(data):
    df = pd.read_csv(data+'.csv', sep=',|;')
    Class_1 = 0
    Class_2 = 0
    Labels = df.iloc[:, -1]
    for items in Labels.iteritems():
        item = items[1].rstrip()
        if item == "ALL":
            Class_1 += 1
        elif item == "AML":
            Class_2 += 1

    print (Class_1)
    print (Class_2)

When I print "items" it returns me a touple and if I print "items[1]" it returns me a str object that correspond to "ALL" or "AML". But the cycle return me 0 for Class_1 and Class_2. I do not know why

Aucun commentaire:

Enregistrer un commentaire