Following this question:

Label expression in ArcGIS gives TypeError coercing to Unicode need string or buffer NoneType found?

I used this python expression in order to create a stacked label from two field: 'name3' and 'results':

"{}\n{}".format([name3], [results])

enter image description here

enter image description here

the problem is that some of the labels contain "None" values that i don't want to represent in the map:

enter image description here

How can i remove the None values and still use the python phrase

I don't want to use VB phrae-i know that in VB the None values disappear from the map and still i prefer to use python.


2 Answers 2


With the use of label classes and filter your data with SQL queries you can label your features depending on their values in one or more fields.

So for your case, the two classes would be (SQL query)

"results" IS NOT NULL
"results" IS NULL

Then you can define different labels for them.

The same can also be done using conditional statements (IF results = None) in the Expression window in Advanced mode. However, this is usually more complicated in my experience.

See this page for help text: http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/displaying-labels-using-label-classes-to-label-fea.htm


Another option would be to field calculate all values that are NULL to '' (empty string) and you can keep your label expression as is, see python parser example below.

def converToNull(myField):
  if myField is None:
    return ''
    return myField

Function call:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.