dimanche 5 août 2018

Comparing c.loc[index, 'MAX'] which is an integer, with an integer is returning an error...

I am checking which pop years have the biggest difference between them. Here is the code. Why is that happening?

    c = census_df[['COUNTY','POPESTIMATE2010', 'POPESTIMATE2011', 'POPESTIMATE2012', 'POPESTIMATE2013', 'POPESTIMATE2014', 'POPESTIMATE2015']]
c['MAX'] = 0 #this is where the biggest difference for each county is stores
for index, row in c.iterrows():
        x = 5
        y = 4
        while x >= 1 & y >= 0: #check how you do the ops
            r = (c['POPESTIMATE201'+str(x)] - c['POPESTIMATE201'+str(y)]).abs()
            '''if r > c.loc[index, ['MAX']]:
                c.loc[index, ['MAX']] = r'''
            c.loc[index, ['MAX']] = r
            x -= 1
            y -= 1
return c

Aucun commentaire:

Enregistrer un commentaire