Currently working on a Median calculation tool. This tool is similar to the one I posted on a previous post involving selecting a city and zooming into it. In this case, we have to type in a country name, where the tool will then select all the cities in that country, sort the POP_RANK of the cities in that country, and calculate the median POP_RANK for that country. I was able to complete the select and zoom aspect but I am not entirely sure how to create a list/search cursor which will allow us to input a calculation. Is there a specific way I should approach this? Any and all help is appreciated!! Thank you
import arcpy
from arcpy import mapping
#sets the workspace
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
fc = ("N:/data2016/Lab13/cities.shp")
cities = arcpy.mapping.ListLayers(mxd, "Cities")[0]
cities.showLabels = True
def countryList():
country = arcpy.GetParameterAsText(0)
country_Layer = arcpy.MakeFeatureLayer_management(fc, "country_lyr")
arcpy.SelectLayerByAttribute_management(cities, "NEW_SELECTION", "CNTRY_NAME = '{}' ".format(country))
arcpy.mapping.ListDataFrames(mxd)[0].zoomToSelectedFeatures()
arcpy.RefreshActiveView()
arcpy.Delete_management("country_lyr")