I am running a Field Calculation within a Python script in ArcGIS. Within this Field Calculation I am calling a defined function within a code block.
Here is the dialogue that I ran and works:
This worked. However, I cannot get this to translate into my Python code:
Here's the code:
#Calculate YSLB expression = "output(!MTH_BRNT!,!YR_BRNT!,!YSLB!)" code_block = "def output(MTH_BRNT,YR_BRNT,YSLB):/n month = str(month_val)/n month_current = int(month)/n month_fire = int(MTH_BRNT)/n year = str(high_year)/n year_current = int(year)/n year_fire = int(YR_BRNT)/n Mc = (12*(year_current-1)) + month_current/n Mf = (12*(year_fire-1)) + month_fire/n return (Mc-Mf)/12" arcpy.CalculateField_management(fuel_age_out,"YSLB",expression,"PYTHON_9.3",code_block)