I have a table and I want to find max and min value in specified field (f1
) with their names. I used this code but I only could print max and min values in f1
. How can I print their names Like the image I put I want to print min value of f1
and its name net72.shp
. I think it must be using WHERE_CLAUSE
.
import arcpy
fc = r"E:\gis payannameh\tabusearch2\SUMMARY.gdb\net38_j"
from arcpy import env
fields = ['f1','FIRST_netw']
all_rows = [i[0] for i in arcpy.da.SearchCursor(fc,fields[0])]
min_val = min(all_rows)
print min_val
Best Answer
List all values, use min/max with a lambda function:
Or you can sort the list and fetch first and last value using indexes: