import arcpy fc="C:/Temp/crimeGrid.shp" fields="'MEAN_GRIDC', 'SUM_Join_C', 'crimeRate') with arcpy.da.UpdateCursor(fc,fields) as cursor: for row in cursor: if (row[0] > 0): row[2] = row[1]/row[0] else: row[2] = 0 cursor.updateRow(row)
import arcpy fc = "C:/Temp/crimeGrid.shp" fields = ['MEAN_GRIDC', 'SUM_Join_C', 'crimeRate'] with arcpy.da.UpdateCursor(fc,fields) as cursor: for row in cursor: if row[0] > 0: row[2] = row[1]/row[0] else: row[2] = 0 cursor.updateRow(row)