ArcGis Python modifies field information based on existing data

Suppose the original data is as follows

 

Field 1 Field 2 Field 3 Field 4 New field
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  
you it is good Is it  

 

 

1. Open the attribute table

2. Add new fields

3. Open the Python editor

     Left-click on the title of the new field to select all, and then right-click on the title to display the field calculator.

4. Settings editor

     The parsing program is changed to: python

     Check [Display code block]

5. Fill in the code

Fill in the [pre-logic script code]:

all_data = {}
def xgmc(dlmc):
  if dlmc not in all_data:
    all_data[dlmc]=0
  all_data[dlmc]+=1
  return dlmc+str(all_data[dlmc])

6. Call in the call box

Fill in the code:

xgmc(!字段1!)

 

7. Click [OK]

Guess you like

Origin blog.csdn.net/usdnfo/article/details/110588268