In the python window, this works as expected:
n = 1313.87
type(n)
<class 'float'>
str(n).split('.')[1]
'87'
HOWEVER, trying to do the same to label features fails:
Note that PtZ is a Double, and the label expression str([PtZ]) labels just fine.
What am I doing wrong here???
Pro version 3.4
Solved! Go to Solution.
Hey @KevinBell1
It looks like when using the label expressions, it's placing a "return" in front of the expression. This normally means you will need to create a function for this, with set return values, something like this here:
def FindLabel([PtZ]):
val = str([PtZ])
parts = val.split('.')
if len(parts) > 1:
return parts[1]
else:
return ''
Let me know if this ends up working for you!
Cody
It can be simplified a bit more even. The [PtZ] doesn't have to be stored in a separate variable, it is already a variable:
def FindLabel([PtZ]):
return [PtZ].split('.')[1]
Hey @KevinBell1
It looks like when using the label expressions, it's placing a "return" in front of the expression. This normally means you will need to create a function for this, with set return values, something like this here:
def FindLabel([PtZ]):
val = str([PtZ])
parts = val.split('.')
if len(parts) > 1:
return parts[1]
else:
return ''
Let me know if this ends up working for you!
Cody
It can be simplified a bit more even. The [PtZ] doesn't have to be stored in a separate variable, it is already a variable:
def FindLabel([PtZ]):
return [PtZ].split('.')[1]
Great! That works, but is some weird ESRI stuff going on since you can't split a float/double!