Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been combing the help associated with (None) values in arc, and have not been able to solve the following problem:

I have a a field with mixed Null and integer values:

0 100

I would like to transform the null values to 0's in python:

   cursor = arcpy.UpdateCursor(fishJoin, ['myField']):

    for row in cursor:
        if row is None:
            row = 0

This does not alter any of the null values.

I'm using ArcGIS Desktop 10.0.

share|improve this question
up vote 9 down vote accepted

I would recommend using the data access module da with the Update Cursor as you will notice significant performance improvements. The following is the correct syntax to replace <Null> (aka None) values with 0.

import arcpy

fc = r'C:\path\to\your\FGDB.gdb\andFC'

with arcpy.da.UpdateCursor(fc, ["Field_Name"]) as cursor:
    for row in cursor:
        if row[0] == None:
            row[0] = 0

print "Processing complete"

The following is the correct syntax for ArcGIS 10.0 (i.e. without the da module).

import arcpy

fc = r'C:\path\to\your\FGDB.gdb\andFC'

cursor = arcpy.UpdateCursor(fc)

for row in cursor:
    if row.YourFieldName == None:
        row.YourFieldName = 0

print "Processing complete"

del row
share|improve this answer
Thanks Aaron. I tried this and received the error: AttributeError: 'module' object has no attribute 'daUpdateCursor' . It seems this is only 10.1 + I am using 10.0 – Sarobinson Mar 11 '14 at 21:31
Great! much appreciated. – Sarobinson Mar 11 '14 at 21:50
Post updated to show correct syntax for 10.1+ and 10.0. – Aaron Mar 11 '14 at 21:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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