1

I have tried all of below snippets to use Python Parser in Field Calculator and update the values of a field called type based on a filed called MamerMN but in all of them I am getting Syntax error in Geoprocessing result window!

if !MamerMN! <= 0.151560:
    return 1

and

if (!MamerMN! <= 0.151560):
    return 1

and

if (MamerMN <= 0.151560):
    return 1

and

def(MamerMN)
if MamerMN <= 0.151560:
    return 1

and

def(MamerMN)
if (MamerMN <= 0.151560):
    return 1

Can you please let me know what I am doing wrong?

Update

def foo(MamerMN):
  if MamerMN <= 0.151560:
     return 1
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Suffii
  • 588
  • 2
  • 8
  • 20

1 Answers1

2

Thanks to Paul

Here is the solution: in Pre-logic Script Code Box:

def foo(MamerMN): 
  if (MamerMN <= 0.200000): 
     return 1
  elif (MamerMN >= 0.200001 and  MamerMN <= 0.400000):
     return 2
  elif (MamerMN >= 0.400001 and  MamerMN <= 0.600000):
     return 3
  elif (MamerMN >= 0.600001 and  MamerMN <= 0.800000):
     return 4
  elif (MamerMN >= 0.800001):
     return 5

and in Expression box

foo( !MamerMN! )
Suffii
  • 588
  • 2
  • 8
  • 20