Bạn có thể sử dụng mô-đun bộ sưu tập Python và Cập nhật con trỏ để thực hiện việc này. Phương pháp này thêm một trường mới và điền vào đó 1nếu có bất kỳ trùng lặp nào, 0nếu không thì không có trùng lặp.
import arcpy, collections
shp = r'C:\temp\names.shp'
# Add a field called "check" to store binary data.
arcpy.AddField_management(shp, field_name = "check", field_type = "SHORT")
# Use an Update Cursor to query the table and write to new rows
# 1 = has duplicates
# 0 = no duplicates
with arcpy.da.UpdateCursor(shp, ["last_names", "check"]) as cursor:
for row in cursor:
names = row[0].replace("&", "").split() # Clean the string
counts = collections.Counter(names) #create dictionary to count occurrences of words
if any(x > 1 for x in list([count for name, count in counts.items()])):
row[1] = 1
else:
row[1] = 0
cursor.updateRow(row)
