My issue is that I am getting an error statement that states the following:
row[0] = row[2] / row[1] * 100
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'
Here is the script I'm using to run the operation
#variables
fieldname1 = "acres2"
fieldname2 = "ac_std2"
fieldtype = "DOUBLE"
where_clause_calc = """"acres2" IS NOT NULL"""
#newfields
arcpy.AddField_management(fc, fieldname1, fieldtype)
arcpy.AddField_management(fc, fieldname2, fieldtype)
#float
with arcpy.da.UpdateCursor(fc, ["StatedAcre", "acres2"]) as cursor:
for row in cursor:
try:
row[1] = float(row[0])
cursor.updateRow(row)
except:
row[1] = -999
cursor.updateRow(row)
del cursor
#calculate
with arcpy.da.UpdateCursor(fc, ["ac_std2","acres2","Area"], where_clause_calc) as cursor:
for row in cursor:
if row[1] > 0.00:
if row[1] < row[2]:
row[0] = row[1] / row[2] * 100
cursor.updateRow(row)
else:
row[0] = row[2] / row[1] * 100
cursor.updateRow(row)
else:
row[0] = -999
del row
del cursor
When I create both fields being used to calculate, I set the field type to DOUBLE. When I open the table in ArcMap the field properties reflect this. What's especially odd is that the updates are performed for about 1/4 of the rows in the table. My questions are why is this error occurring while both field types are DOUBLE, and what can I do to fix this issue?