0

I have an issue with my code. I am using ArcMap 10.8 and I am trying to create a sequence of numbers, taking into account one sorted field (the field "Latitude"). My code is the following one:

mxd = arcpy.mapping.MapDocument("Operating.mxd") #Pre-Logic Script Code: Set the mxd to be used`

lr=arcpy.mapping.ListLayers(mxd)[0] #Specify that the target layer is the first layer in the table of conten tbl=arcpy.da.TableToNumPyArray(lr,("Label","Latitude"))

bs=sorted(tbl,key=lambda x: x[1])
aDict={}

for i,row in enumerate(bs): aDict[row[0]]=i+1 def sortSeq(Label): return aDict[Label]
sortSeq(!Label!) #Expression #to run the code, the following goes in the expression window`

Despite that the first time the code worked, when I repeated the process, it gives me an error that refers to the following (attached screenshot).attached screenshot

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
StavGian
  • 39
  • 4
  • 2
    What does the geoprocessing result window report? – BERA Dec 13 '21 at 11:19
  • Can you add a screenshot showing a sample of the attribute table and your expected result? – BERA Dec 13 '21 at 11:26
  • Unfortunately, I can't find a way to add a screenshot of the desired result. I want an attribute table that will have sequential values, just like the post from the previous year (https://gis.stackexchange.com/questions/193681/calculating-sequential-numbers-into-sorted-table-using-arcgis-desktop). As for the received error, I change the code a little bit, setting at the 4rth line: bs=sorted(tbl,key=lambda x: x[0], x[1]), because it referred that there was an issue with the number of parameters. But right now it shows me that there is an issue with the line 11 (error 000539). – StavGian Dec 13 '21 at 12:05
  • Thanks, @BERA. I will do it that way! – StavGian Dec 13 '21 at 12:19

0 Answers0