HOW TO

Remove leading zeros in labels using Arcade or Python expressions in ArcGIS Pro

Last Published: July 4, 2024

Summary

In ArcGIS Pro, some fields may contain leading zeros. Often, leading zeros are not required when displaying field values as labels for better data integration and map visualization. The leading zeros can be removed from the fields in the attribute table in ArcGIS Pro. This article provides the workflow to remove leading zeros when displaying labels using a Python or Arcade expression while retaining the leading zeros in the attribute table in ArcGIS Pro.

Labels with leading zeroes.png

Procedure

  1. Open the ArcGIS Pro project, add the layer, and create the label expression. For instructions, refer to steps 1 through 4 in ArcGIS Pro: Write a label expression, and select Arcade or Python from the Language drop-down list.
Note:
In the Contents pane, ensure the feature layer and feature class check boxes are checked to display the labels.
  1. In the Label Class pane, configure the following parameters in the Expression box:
  • For Arcade, replace <field_name> with the name of the field to be displayed as labels.
Number($feature.<field_name>)
Label Class pane with Arcade configuration.png
  • For Python, replace 'Field_name' with the name of the field to be displayed as labels.
[Field_Name].lstrip("0")
Label class pane with Python configuration.png
  1. Click the Verify button to validate the expression.
  2. Click Apply to run the script.

The image below displays the data without leading zeros in the labels.

Labels without leading zeroes.png

Article ID: 000031502

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 3 2

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options