I have a column X in attribute table where the values are repeated in some lines. What I need is to make a condition that says: when the values in column X are the same, find the minimum of column Y and write it in a new column.
My attribute table is something like this:
My knowledge in python is very limited. I'm trying the code below but it's not working, has a syntax error, and if I put "if" instead of "elif" it works but results 0 in all lines, and what I want is to write "Y" or "0" in each line.
def func (code,w,ataq): Y=w*ataq if X == 0: return 0 else: if X == X + 1: m=min(Y) elif Y == m: return Y else: return 0
The problem is in the incrementation of X. How can I do this differently?
UPDATE Now I'm trying this code on python window:
import arcpy featureClass="C:\\Users\\andreia.medeiros\\Documents\\ArcGIS\\Trabalho\\Modelo\\linhas_150_5km.shp" data=arcpy.SearchCursor("linhas_150_5km","","","Line_code;w_min;ang_ataque","Line_code;w_min;ang_ataque") import collections d=collections.defaultdict(list) for Line_code,w_min,ang_ataque in data: d[Line_code].append(w_min*ang_ataque)
But there's something wrong with "data". When I print "data" it shows "geoprocessing cursor object object at 0x1DAED2A0" And I have a TypeError: 'Row' object is not iterable
Any help to figure it out what is wrong here?