I am trying to calculate field with the formula. I tried arcpy.calculate field management but still having difficulty.
(10/10.4*(100*(math.exp(0.000871* !A!)-1+math.exp(0.000537* !B! )-1+math.exp(0.000487* !C! )-1)))
I used the below code.
with arcpy.da.UpdateCursor(fc, (VALUE, A, B, C)) as cursor: for row in cursor: row[0] = (10/10.4*(100*(math.exp(0.000871* !A!)-1+math.exp(0.000537* !B! )-1+math.exp(0.000487* !C! )-1))) cursor.updateRow()
1 Answer 1
#You need to reference each Field its Index in your list of Fields.
# what values are in A,B,C? string, integer,double? you may need to cast them
with arcpy.da.UpdateCursor(fc, ['VALUE', 'A', 'B', 'C']) as cursor:
for row in cursor:
calc_a = math.exp(0.000871* row[1])-1
calc_b = math.exp(0.000871* row[2])-1
calc_c = math.exp(0.000871* row[3])-1
row[0] = (10/10.4 * (100* (calc_a + calc_b + calc_c))))
cursor.updateRow()
{}
button in the editor. The result will be legible code (and fewer downsides)