How To: Replace null values with zero in an attribute table
The instructions provided describe how to replace null values with zeros in an attribute table using the Field Calculator in ArcMap. In this example, Python code is used to replace null values in a field without having to edit every record individually.
To replace null values with zeros in a field in an attribute table, follow the steps below:
In ArcMap, click the Editor drop-down menu on the Editor toolbar, and select Start Editing.
In the Table Of Contents, right-click the selected layer, and select Open Attribute Table.
Right-click the field with null values, and click Field Calculator.
In the Field Calculator, select the Python parser, and check the Show Codeblock check box.
In the Pre-Logic Script Code box, copy and paste the following code:
if value == None:
else: return value
Type the following code in the second box, and replace '!Field_Name!' with the field name from the Fields list, as shown in the image below.
Click OK, and the null values are replaced with zeros in the field, as shown in the image below.
In the Editor toolbar, click Stop Editing and Save Edits to keep the changes.