I first classified firstCol into groups and then I want to give the groups with different weighted values in another field, SecondCol. I will need to give different weighted values very often. I find it very time-consuming whenever I modify the weighted values in my script.
My column looks like this:
I use the following script to calculate the SecondCol:
def TextValue(gridcode):
if gridcode <= 5:
    return 1
elif  5 < gridcode <= 15:
    return 2
elif  15 < gridcode <= 30:
    return 3
elif  30 < gridcode <= 40:
    return 4
elif  40 < gridcode <= 55:
    return 5
elif  55 < gridcode <= 100:
    return 6
elif  100 < gridcode :
    return 7
else:
    return "N/A"
TextValue( !firstCol! )
As you can see, I give the weighted value as below:
(weighted values  ,  group).
1   =   group "firstCol  < 5"    
2   =   group "firstCol = 5 - 15"    
3   =   group "firstCol = 15 - 30"    
4   =   group "firstCol = 30 - 40" 
5   =   group "firstCol = 40 - 55"    
6   =   group "firstCol = 55 - 100"    
7   =   group "firstCol > 100"
I wonder if there is a better way to give new weighted values more efficiently. Like, just give a new column in the beginning of the script.
61  =   group "firstCol  < 5"   
8   =   group "firstCol = 5 - 15"    
88  =   group "firstCol = 15 - 30"    
70  =   group "firstCol = 30 - 40"   
52  =   group "firstCol = 40 - 55"    
2   =   group "firstCol = 55 - 100"    
6   =   group "firstCol > 100"
def TextValue( gridcode):
if ...
...
else...
TextValue( !firstCol! )
Then, the script will use the new values, instead of me modifying it in the TextValue.


