I want to assign numbers to a field, WScore (double), based on field values of Soils (string). They are in the same table of a raster. I'm not trying to add text to a double. What I want to do is this: Where Soils = Ds, Oo, Mu, P, or Se, WScore = 2.5.
I have little python experience so any guidance would be really helpful. Here's what I've come up with so far.
Expression:
WScore=Reclass(!SOILS!)
def Reclass(Soils):
x=1
if (Soils == "Ds"):
x=2.5
elif (Soils == "Oo"):
x = 2.5
elif (Soils == "Mu"):
x = 2.5
elif (Soils == "P"):
x = 2.5
elif (Soils == "Se"):
x = 2.5
I'm getting error 000539, which I'm guessing is because I can't concatenate 'str' and 'int' objects, though this error # covers many.
if Soils in ['Ds','Oo','Mu','P','Se']: return 2.5
is a bit terser given you assign the same numerical value to these.