I'm new to coding and I need to somehow use an Update Cursor that I can convert the rates of crashes in a block group into 3 separate categories. The crash rate is the difference between the number of crashes in a block group divided by sum of all road lengths in the block group. The update cursor needs to go through my crash_rate field and then place them in my crash_category field. Category 1 is low, category2 is medium, and category 3 is high. My Max crash rate is 373.35998535, my average / mean crash rate is 51.8848051, and my lowest crash rate is 0. Here's the code that I used to find the Max, Min, and Mean:
import arcpy import sys import os fc = r"C:\GISAutomation\Project\GISAutoProject\GISAutoProject.gdb\F2F_BG_crash" #field = "crash_ratio" num_sum = 0 num_counter = 0 maximum = 0 minimum = 0 #cursor = arcpy.da.SearchCursor(fc,["crash_ratio"]) if arcpy.Exists(fc): print("exists") with arcpy.da.SearchCursor(fc,["crash_ratio"]) as cursor: for row in cursor: num_sum = num_sum + row num_counter = num_counter + 1 if row> maximum: # doing the comparisons to find the maximum value maximum = row  if row< minimum: minimum = row  num_average = round(num_sum / num_counter,2) print ("The average per blockgroup is", num_average, "miles") print ("The minimum per blockgroup is", round(minimum,3), "miles" ) print ("The maximum per blockgroup is", round(maximum,2), "miles") print ("script 1 finished")
Does anyone have any advice about how I can set my update cursor to place the different values into either high, medium, or low categories? I'm really lost.